I have run into a bit of a problem here: I had a problem-specific branch 28s
in Git, that I merged in the general develop
branch. Turns out I had d
I would suggest you to follow below steps to revert a revert, say SHA1.
git checkout develop #go to develop branch
git pull #get the latest from remote/develop branch
git branch users/yourname/revertOfSHA1 #having HEAD referring to develop
git checkout users/yourname/revertOfSHA1 #checkout the newly created branch
git log --oneline --graph --decorate #find the SHA of the revert in the history, say SHA1
git revert SHA1
git push --set-upstream origin users/yourname/revertOfSHA1 #push the changes to remote
Now create PR for the branch users/yourname/revertOfSHA1
At this point you'll have a clean 'develop' branch to which you can merge your feature brach as you regularly do.
To revert a revert in GIT:
git revert <commit-hash-of-previous-revert>
Instead of using git-revert
you could have used this command in the devel
branch to throw away (undo) the wrong merge commit (instead of just reverting it).
git checkout devel
git reset --hard COMMIT_BEFORE_WRONG_MERGE
This will also adjust the contents of the working directory accordingly. Be careful:
git-reset
. All commits after the one you specify as
the git reset
argument will be gone!I recommend to study the git-reset
man-page carefully before trying this.
Now, after the reset you can re-apply your changes in devel
and then do
git checkout devel
git merge 28s
This will be a real merge from 28s
into devel
like the initial one (which is now
erased from git's history).
Let's assume you have such history
---o---o---o---M---W---x-------x-------*
/
---A---B
Where A, B failed commits and W - is revert of M
So before I start fixing found problems I do cherry-pick of W commit to my branch
git cherry-pick -x W
Then I revert W commit on my branch
git revert W
After I can continue fixing.
The final history could look like:
---o---o---o---M---W---x-------x-------*
/ /
---A---B---W---W`----------C---D
When I send a PR it will clearly shows that PR is undo revert and adds some new commits.
To revert the revert without screwing up your workflow too much:
Your feature branch should now be able to be merged as normal when you're ready for it. The only downside here is that you'll a have a few extra merge/revert commits in your history.