반응형
Existing Repo
Remote
- 목적지 URL.
현재 목적지를 확인.
git remote -v
새 remote를 추가
- 표준 이름은 origin이기 때문에 name에 origin을 입력.
- 단지 URL의 별칭일 뿐.
git remote add <name> <url>
현재 디렉토리가 작업을 진행중인 경우
1. github에서 new repository를 생성한다.
2. 현재 무엇을 가리키고 있는지 확인한다.
git remote -v
3. 원격 저장소에 주소를 불러온다.
git remote add origin URL
4. git push로 remote에 branch를 보낸다.
git push <remote> <branch>
4-1. origin이라는 원격에 main or master branch를 보낸다.
git push origin master
git push origin main
* 기존의 원격저장소 주소를 삭제한다.
git remote rm origin
* 로컬 브랜치를 다른 브랜치로 업로드한다.
git push <remote> <localBranch>:<anotherBranch>
새롭게 작업을 시작하는 경우
1. github에서 new repository를 생성한다.
2. git clone으로 저장소를 나의 디렉토리에 clone 한다.
git clone URL
이하는 동일.
git push -u 의 뜻
upstream을 의미하며 github에 있는 main or master branch를 가리킨다.
해당 branch를 upstream으로 설정하며 push하여 후 git push만으로도 push가 가능해진다.
git push -u origin <branch>
→
git push
반응형
'Git' 카테고리의 다른 글
[GitHub] Fetching & pulling (0) | 2022.12.28 |
---|---|
[GitHub] Remote Tracking Branches (0) | 2022.12.28 |
[GitHub] SSH Keys (0) | 2022.12.28 |
[Git] Cloning (0) | 2022.12.28 |
[Git] Merging (0) | 2022.12.26 |