[Git] git game - push/fetch/pull origin

2024. 7. 10. 11:42Git

728x90
반응형
SMALL

git checkout -b [branch name] [remote branch name]

 

새로운 브랜치를 생성하는데 특정 원격 브랜치를 참조하는 브랜치를 생성

-push 및 pull 시 목적지를 해당 원격 브랜치로 설정

 

git branch -u [branch name] [romote branch name] 도 같은 기능을 함

 

 

git push origin [source]:[destination]

 

local의 [source] commit을 remote의 [destination] branch에 push

- [destination] branch 없으면 생성

- [source] commit 없으면 [destination] branch를 삭제

 

 

git fetch origin [source]:[destination]

 

remote의 [source] commit을 local의 [destination] branch에 fetch

- [destination] branch 없으면 생성

- [source] commit이 없으면 local에 [destination] branch 생성

    - local에 이미 존재하는 브랜치명을 [destination]으로 설정하면 명령어 거부됨

 

 

git pull origin [source]:[destination]

 

git pull origin foo = git fetch origin foo; git merge o/foo

git pull origin bar:bugFix = git fetch origin bar:bugFix; git merge bugFix

- local에 [destination] branch 없으면 생성

- checkout된 브랜치로 merge함

 


 

git game 정답

 

git checkout main
git pull
git rebase -i main side1
git rebase -i side1 side2
git rebase -i side2 side3
git branch -f main side3
git checkout main
git push origin main

 

 

git checkout main
git pull
git merge side1
git merge side2
git merge side3
git push origin main

 

 

git checkout -b side o/main
git pull
git branch -f side c1
git commit
git rebase o/main side
git push origin side

 

 

git push origin main
git push origin foo

 

 

git push origin foo:main
git push origin main^:foo

 

 

git fetch origin c3:foo
git fetch origin c6:main
git checkout foo
git merge main

 

 

git push origin :foo
git fetch origin :bar

 

 

git pull origin c3:foo
git pull origin c2:side
728x90
반응형
LIST