Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I sync my local master branch after merging a pull request on GitHub?

Tags:

git

github

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?
like image 717
Alaa Ali Avatar asked Nov 02 '16 02:11

Alaa Ali


1 Answers

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.

like image 97
tymtam Avatar answered Oct 06 '22 15:10

tymtam