gitlabcherry-pick

Undo or revert a single, earlier GitLab cherry-pick commit?


I committed like 10 individual cherry-picked changes to my new release branch, and now after regression testing found that one of those commits in the middle may have broken something. I am prepared to release a new version of the code but exclude that commit. Must I start over cherry-picking into the new release branch to do this right, or is there a way I can simply copy my current branch into a new release branch and revert or undo the single offending commit without losing those that came before or after it?


Solution

  • I ended up creating a new release branch and starting over, cherry-picking into the new release branch the individual commits that I wanted and skipping the one I didn't want.

    There is also another method I learned but didn't use--which is,

    git revert <commit-hash>
    

    However, while it does undo a commit in the branch where it exists so that the resulting code is devoid of that commit's changes, git revert does create a new revert-related commit in the git log for that branch to undo the unwanted commit--so it's not really a clean, make-like-it-never-happened erasure because you'll still see it in the branch's history.