happybuddha
happybuddha

Reputation: 1358

Git merge updated develop branch into local branch

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 ?

Upvotes: 9

Views: 31707

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522581

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.

Upvotes: 20

Related Questions