Much too often, when working with Git and working on long time pull requests, I tend to screw up the Git history. For that reason, I often have to cherry pick a commit into a new branch and push that one upstream to the feature branch – with force.
First, identify the actual commits you want to cherry pick. You need to get the correct hash there. Then, create a new branch, cherry pick the commit, force the new branch upstream, delete the old branch, and rename the new one.
git log --author liquidat git branch mywork_feature_tmp git cherry-pick abcdefgh123456 git push --force origin HEAD:mywork_feature git checkout devel git branch -D mywork_feature git branch -m mywork_feature_tmp mywork_feature
My hope is that in some point in the future I will be able to fix such broken Git repos at that point without cherry-pick. But until then, the current way works for me…
Filed under: Debian & Ubuntu, Fedora & RHEL, Linux, Shell, Short Tip, Technology