9

How do I go about updating a branch that I have checked out, with the updated (which has had a few pull requests merged, after the local branch was branched off of develop) develop branch ? At the moment, if I am on branch_1 with un/committed/pushed changes, I do a

git checkout develop
git pull
git checkout branch_1
git merge develop

Is there a way with lesser steps to achieve what I am after ?

happybuddha
  • 1,271
  • 2
  • 20
  • 40
  • 1
    Possible duplicate of [Get changes from master into branch in Git](https://stackoverflow.com/questions/5340724/get-changes-from-master-into-branch-in-git) – Emily Apr 23 '18 at 00:35

1 Answers1

20

If you want to update branch_1 via merging, then there is a slightly shorter version of doing this:

git fetch origin
git checkout branch_1
git merge origin/develop

By doing a git fetch, you automatically update the remote tracking branch for develop, which is called origin/develop. Note that the local branch develop would not be updated, but it doesn't matter, because you can merge with the tracking branch.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360