Keracon

#1. git fork & rebase

현불 2019. 9. 28. 17:33

1) fork 해 올 repository(예시는  https://github.com/Keracorn/HashTag)에서 상단 뒤 fork 버튼을 눌러 내 repository에 추가한다.

 

2) 추가하고 나면 다음과 같이 내 repository에 추가가 된다.(https://github.com/hyunbul/HashTag.git)

 

3) git clone <fork 해 온 """내""" repository 주소>(예시에서는 git clone https://github.com/hyunbul/HashTag.git)으로 파일들을 받아온다.

 

4) upstream을 추가한다. 이때 주소는 내 repository가 아니라 fork 했던 원 repository이다(예시

git remote add upstream https://github.com/Keracorn/HashTag.git)

 

5) git fetch upstream <브랜치명>으로 upstream의 브랜치를 가지고 온다. 

(원래는 master 브랜치에 바로 올리면 안되지만, 편의상 바로 master에 commit을 하였기 때문에 여기서는 master 브랜치를 가지고 온다.ㅠㅠ)

6) git rebase upstream/<브랜치명>으로 rebase를 한다.

 


 

이제 내 repository에 파일을 올린다.

 

7) git add <파일명> -> git commit -m "메시지"

 

8) 내 repository에 push한다,(git push origin <브랜치명>)

 

9) 내 repository를 확인해보면 추가되어 있는 것을 볼 수 있다.

 


 

업데이트 사항을 내 repository와 동기화 시키기 위해서는 

 

10) git fetch upstream으로 upstream repository의 최신 업데이트를 가져온 다음 git push origin <브랜치명>으로 내 repository에 추가한다.

 

11) git merge upstream/master

 

12) git push origin <브랜치명>으로 내 repository에 올려준다,

 

13) 추가되어 있는 것을 확인할 수 있다!