Recently I accidentally committed changes to master that I want to commit in a feature branch..... I made the mistake of
- branching master (to a feature branch) from my erroneous commit - then
- resetting (HARD) master to the previous commit
This axed all my history in my feature branch as the commit which I branched from in master no longer existed....
To fix I had to create a new feature branch from master, then create a patch of the differences between my original feature branch and master doing the following:
git checkout master git checkout -b [new_feature_branch] git diff --no-prefix origin/[busted_feature_branch] > my.patch
then apply the patch:
patch -p0 < my.patch