13

I realize there are many questions on syncing branches, and the difference between git commands, but I am finding it hard to know what is the correct process for this.

I am the maintainer of a repository on GitHub. One of the members on my team cloned the repo, created a new-feature branch, pushed this new-feature branch into the GitHub repository, and created a pull request to merge it into master. I approved the pull request and merged it into master on the GitHub website.

What is the correct process to pull this 'new master' down to update my local repository so I have my local directory synchronized, cleanly and without re-writing any history?

  1. git pull --> essentially does a git fetch then git merge...into the branch I'm on?
  2. git pull --rebase --> essentially does a git fetch then git rebase ?
  3. git fetch then git merge origin/master --> same as option 1?
  4. git fetch then git rebase origin/master --> same as option 2?
0

1 Answer 1

7

git pull or git pull --rebase are the canonical ways to achieve what you need - sync your local branch with the branch it follows on the server.

Generally speaking, if you use pull requests, you don't want to make any direct changes to the master branch - everything should go via branches. This strategy (it's not a technical requirement) is a common methodology that teams around choose. One benefit is that you never have merge issues when pulling master.

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

2 Comments

On which branch should that be executed? Checkout master first, and then? Also, the problem is that it can happen that the branch is deleted on GitHub, so I'm left with a local one not merged and dangling around.
@makons pull works in the context of the branch that is currently checked out (The fetch part of pull downloads all remote branches, but the merge part of pull merges the appropriate remote branch into the currently checkout out branch only)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.