I did a dumb thing with git. I had (good) loocal changes to file_a, which I had committed but not pushed. My coworker made (bad) changes to file_a, which she then pushed. I pulled her changes, and rebased them in without fully realizing what was going on. Now file_a is hopeless borkered up, and I'm not sure how to fix it.
Obviously, in the future, pushing more often is one key. What I'd like to do now is undo the rebase, and redo it more thoughtfully. I want to make sure I don't lose my local commits, though, and I'm not sure how to do that.
If I do this command: git reset --hard ORIG_HEAD
, will that preserve my two local commits? Or should I do something else?
Update:
I ended up finding the good commits using the reflog. Then, I cherry-picked them in using another branch and verified that everything was working as expected. Then I used git revert fix_rebase_branch --hard
in my original branch.