简体   繁体   中英

How do I sync my local master branch after merging a pull request on 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM