Development/Etc

GitHub에서 fork한 git간 sync 맞추기

비완 2013. 10. 30. 10:51
반응형

공동작업을 위해 한 git을 각각 fork해서 사용하는 경우가 있다.

이 경우 base git에 다른 사람이 올린 commit으로 인해 내가 base git으로 올리는 git이 conflict 되는 경우가 발생하는데 다음과 같이 하여 sync를 맞추면 된다.

(이때 conflict 이 발생할 수 있는데, 이 경우에는 mergetool로 해결하자)

$ git remote -v
# List the current remotes
# origin  https://github.com/user/repo.git (fetch)
# origin  https://github.com/user/repo.git (push)

$ git remote add upstream https://github.com/otheruser/repo.git
# Set a new remote

$ git remote -v
# Verify new remote
# origin    https://github.com/user/repo.git (fetch)
# origin    https://github.com/user/repo.git (push)
# upstream  https://github.com/otheruser/repo.git (fetch)
# upstream  https://github.com/otheruser/repo.git (push)


$ git fetch upstream
# Grab the upstream remote's branches
# remote: Counting objects: 75, done.
# remote: Compressing objects: 100% (53/53), done.
# remote: Total 62 (delta 27), reused 44 (delta 9)
# Unpacking objects: 100% (62/62), done.
# From https://github.com/otheruser/repo
#  * [new branch]      master     -> upstream/master


$ git branch -va
# List all local and remote-tracking branches
# * master                  a422352 My local commit
#   remotes/origin/HEAD     -> origin/master
#   remotes/origin/master   a422352 My local commit
#   remotes/upstream/master 5fdff0f Some upstream commit


$ git checkout master
# Check out our local master branch
# Switched to branch 'master'

git merge upstream/master
# Merge upstream's master into our own
# Updating a422352..5fdff0f
# Fast-forward
#  README                    |    9 -------
#  README.md                 |    7 ++++++
#  2 files changed, 7 insertions(+), 9 deletions(-)
#  delete mode 100644 README
#  create mode 100644 README.md


출처 : https://help.github.com/articles/syncing-a-fork

반응형