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 ?
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
In a good workflow, the feature branch is deleted once its merged back into master. New branches should be created for each new feature(s) that you work on.
First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch. Note: git merge merges the specified branch into the currently active branch.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With