1

I'm not very familiar with git and just use the common commands. I forked a repository from github.com to my own account, and checked it into my local machine and create a new branch to make some development, thus my modifications are pushed into the new branch, the original master is still in the version when I forked. But, the original repository is still alive and updated frequently, now I want to update my forked repository with the updates in the original repository, how could I do to avoid the inflicts?

1 Answer 1

1

You have two general choices: Rebase or Merge.

Rebase

Rebasing takes the committed changes you have made and rewrites them as if they had been written against the newest revision of the master branch. To do this, make sure your work is committed on your branch and then:

git checkout master
git pull --ff-only
git checkout your-branch
git rebase master

You may get merge conflicts which you will have to resolve. See the documentation for details.

Merge

Merging takes the two histories (the master history and your work) and merges them together. To do this, make sure your work is committed on your branch and then:

git checkout master
git pull --ff-only
git checkout your-branch
git merge master

You may get merge conflicts which you will have to resolve. See the documentation for details.

The choice of whether to do a rebase or a merge is largely one of preference. If you have changes that you have not shared with anybody else, then a rebase is often appropriate because it keeps your history more linear. However, if you have shared your changes with anybody else, then you definitely want to do a merge because that does not modify the commits that have already been made.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.