OK, so our general git structure is that we have a master branch, one or more release branches and then feature branches. All the primary development happens in the feature branches but bug-fixes will sometimes get committed directly to the release branches.
While merging some features into a release branch, there was a bad merge but we didn't notice it until a couple bugfixes were committed afterwards. Some of the feature branches were deleted after merging (something we will alter our workflow to only do after an actual release has occurred in the future). If they hadn't been deleted, we would just scrap the release branch and redo it.
I'm now trying to eliminate this bad merge. I created a new release branch from the release branch prior to the merge.
git checkout <hash prior to merge>
git checkout -b new_release_branch
git merge feature_branch_which_resulted_in_bad_merge_before
This branch is now the way we want it but I still need to bring in the few (less than 5) commits that were made to release_branch after the bad merge. But I can't figure out how to do it. I thought that cherry-pick was the way to go but when I try I get:
$ git cherry-pick fa4a761
error: fa4a761: can't cherry-pick a blob
fatal: cherry-pick failed
$ git cherry-pick 44923992349dae68d982dd305a289ba63f8f6d0b
fatal: bad object 44923992349dae68d982dd305a289ba63f8f6d0b
Note that the above hash is copy/pasted out of gitk but it doesn't show up in any git log for any of my branches.
I also went back and checked and all of the commits I'm trying to fix right now and they are all the same. I'm not sure what that means or why they would show up in gitk but not in git log (where is gitk getting the information?).
OK, Update time. Here is the rest of the story that I left out. When I discovered the broken merge, I created a new clone of the repo to "play with" from our central repo.
Turns out all of the problem commits were never pushed from the original copy of the repo to the central repo. Once I pushed those commits, I was able to fix everything up just fine.
git fsck
to perform an integrity check of your repository. – Fateful