Justin Meltzer
Justin Meltzer

Reputation: 13548

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 my new code in the side branch?

Upvotes: 0

Views: 3912

Answers (2)

user229044
user229044

Reputation: 239311

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.

Upvotes: 4

CharlesB
CharlesB

Reputation: 90316

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.

Upvotes: 0

Related Questions