Reputation: 1890
I realize that there have been similar questions posted about this subject; I'm afraid I'm not grasping the best way to recover from this situation. I'm using SourceTree on Windows.
I branched from dev, made some commits to a handful of files, pushed to the remote, and merged back into dev. It turns out that there are many pre-existing commits in dev that are not going to be ready to be promoted to master any time soon, and I really should have branched from master instead.
So I made a new branch from master, and I then cherry-picked the commits from the original branch which I know are good. One wrinkle is that two of the files that I originally modified will have different changes in the new branch.
However, I'm unsure as to best handle the process of resetting the dev branch back to the state it was in prior to the two merges that I made. Should I:
Here's the graph. The left-most branch is the original branch from dev. The next branch is the new branch from master, with cherry-picked commits. The blue line is the commit that I want to reset dev back to. Thanks!
Upvotes: 1
Views: 517
Reputation: 4215
Given that NO ONE has pulled from the remote develop
branch yet, all what you need to do is to overwrite what commit the branch develop
is pointing at, and follow those command to do that:
# Change your local develop to point that old version of that branch
git checkout -B develop <commit-hash-of-blue-line-in-pic>
# FORCE push your local develop to the remote develop
git push origin -f develop
Upvotes: 1