JohnSnow
JohnSnow

Reputation: 7111

Merging a commit off of one branch, to be based off of another branch

I have a master branch and a staging branch for my project. I just pushed up a separate develop branch that is off of master, but I need it to be off of staging.

Is there anyway to take the develop branch which is 1 commit ahead of master and have it so it is off of my staging branch? So ultimately it would only be one commit ahead of staging?

Upvotes: 1

Views: 30

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521093

I might be tempted to suggest doing a simple rebase of develop on staging:

git checkout develop
git rebase staging

This would replay all the commits in develop which occurred after the point where staging diverged from master directly on top of the staging branch. But this might also play certain master commits on top of staging, which does not sound like what you want.

So if all you want to do is to play that single commit on top of staging and have it be the develop branch, you can try this:

git checkout staging
git checkout -b new_develop
git cherry-pick <SHA-1 of single commit>

Then delete the old develop branch, and rename new_develop to develop:

git branch -d develop
git branch -m new_develop develop

Upvotes: 1

Related Questions