开发者

Pulling master from Github from a side branch

I'm working on a separate branch from the master branch, and I wondering what will happen if I pull the latest changes from Github. Should I pull from the master branch or the side branch? If I pull from the side branch, will it just merge the updates with 开发者_如何学JAVAmy new code in the side branch?


You want to

  1. fetch changes to origin/master
  2. merge origin/master into your local master branch
  3. merge your master branch into your feature branch

If your master hasn't changed you should:

git checkout master
git pull # fetches (step 1) and merges (step 2)
git checkout <my branch>
git merge master # (step 3)

If your local master has changed, git pull may cause merge conflicts that you will have to resolve. If you want to keep your history clean, you might consider git pull --rebase and/or rebasing your feature branch onto the newly merged master once steps 1 and 2 are complete.


If you pull from a local branch, you have to specify what remote branch you want to pull from. So if you specify that you want to pull from the master remote branch, changes that happened on it will get merged in your local branch:

git pull <github-repo-url> master

Then to update your local master branch, check it out and run the same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜