자꾸 헷갈려서 각 case 별 방법 정리

 

1. Remote Branch에 있는 Branch로 이동

git fetch
git checkout other-branch

git fetch는 메타 정보만 불러옴

 

2. Remote Branch Update 내역 Local Branch에 적용

git checkout other-branch
git pull

업데이트하려는 branch에서 git pull을 하면 Remote Branch에서의 업데이트 내역이 반영됨

 

3. Remote Origin Update 내역 Local Origin에 적용

git checkout other-branch
git pull origin main

업데이트하려는 branch에 main branch의 update 내역이 반영됨

 

4. Local Branch -> Remote Branch

git checkout other-branch
# 작업...
git add --all
git commit -m "comment"
git pull # 내가 commit 하기 전에 다른 사람이 remote branch에 commit했을 경우
git push origin other-branch

5. Local Branch -> Remote Origin Branch (PR로 보통 branch 충돌을 점검해야 하므로, 거의 쓸일 없을 듯)

git checkout other-branch
# 작업...
git add --all
git commit -m "comment"
git pull origin main # 내가 commit 하기 전에 다른 사람이 remote branch에 commit했을 경우
git push origin other-branch:main # git push origin <local>:<remote>

 

Reference

 

Git - ( local / remote ) branch 사용법 정리

Git 명령어 Fetch -> 리모트 저장소에 있는 모든 데이터를 로컬로 가져옴. Git branch [브랜치명] => 새로운 브랜치 생성 Git checkout [브랜치명] => 브랜치 checkout(다른 브랜치로 이동) Git commit => ———> 한

jw910911.tistory.com

 

Git - git-push Documentation

In general, URLs contain information about the transport protocol, the address of the remote server, and the path to the repository. Depending on the transport protocol, some of this information may be absent. Git supports ssh, git, http, and https protoco

git-scm.com

+ Recent posts