DEV Community

Cover image for Merging Changes from another Local Branch
John Peters
John Peters

Posted on • Updated on

Merging Changes from another Local Branch

But...officer the ship is still salvagable!

Scenario:

We make a bunch of changes and commit them only to find out we were on the master branch. How do we solve this problem? Any attempts to push to master are never allowed.

git checkout -b 'NewBranchName'
// should be in that branch now
git merge master
// all the commits on master are brought over to new branch
git push
//all changes are pushed up via the new branch!

Enter fullscreen mode Exit fullscreen mode

Ah, yes! We saved the ship from sinking.

JWP2020

Top comments (0)