I was working on my feature branch
and after review, merged it into development
to be deployed. Later, a coworker decided to do a release and merged his and mine into master
. While deploying he realized his code was buggy and reverted master
.
In our fork-and-pull flow, that means that now development
and master
are both reverted.
When I came in this morning, I rebased from development per usual, to learn afterward there had been a revert.
Now I'm trying to cherry-pick
my work from the original feature branch
only to realize it gives me "empty commit messages" because of the revert.
Any help is greatly appreciated.
The git revert commit command is substantially similar to the command git cherry-pick commit with one important difference: it applies the inverse of the given commit . Thus, this command is used to introduce a new commit that reverses the effects of a given commit.
A cherry-pick is basically a commit, so if you want to undo it, you just undo the commit. Stash your current changes so you can reapply them after resetting the commit.
I found the answer is git reset --merge - it clears the conflicted cherry-pick attempt.
If a commit being cherry picked duplicates a commit already in the current history, it will become empty.
Cherry-pick and rebase checks the patch id of the commit (basically a hash of the change) and already sees that the change exists on the branch, so it doesn't pick it. Rebasing can sometimes work because changes in the files may have caused the actual diff to change a bit--resulting in a different patch id--but that doesn't appear to be the case for you.
You can "revert the revert", though that will re-introduce the broken bits your co-worker introduced. Then you need to revert the buggy commits your co-worker made. It's a lot of reverting, and quite a bit to keep straight, so take it slow and have someone sit with you just to make sure you don't miss anything.
Another choice might be to replay your commits by doing git show COMMIT_ID | git apply
. This re-applies the diff to your working tree. As long as your tree is clean, you can use git commit -C COMMIT_ID
to re-use the message from the original commit. You can probably use git format-patch
and git am
to avoid the extra steps.
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