How can I keep my branch up to date with master with git?

GitGithub

Git Problem Overview


I have a bug fix in my master, and I also want my branch to get that bug fix. What git command do I use?

Git Solutions


Solution 1 - Git

Assuming you're fine with taking all of the changes in master, what you want is:

git checkout <my branch>

to switch the working tree to your branch; then:

git merge master

to merge all the changes in master with yours.

Solution 2 - Git

If your branch is local only and hasn't been pushed to the server, use

git rebase master

Otherwise, use

git merge master

Solution 3 - Git

You can use the cherry-pick to get the particular bug fix commit(s)

$ git checkout branch
$ git cherry-pick bugfix

Solution 4 - Git

If you just want the bug fix to be integrated into the branch, git cherry-pick the relevant commit(s).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNic HubbardView Question on Stackoverflow
Solution 1 - GitJohn DotyView Answer on Stackoverflow
Solution 2 - GitChetanView Answer on Stackoverflow
Solution 3 - GitmanojldsView Answer on Stackoverflow
Solution 4 - GitAlan Haggai AlaviView Answer on Stackoverflow