ygr
ygr

Reputation: 383

Git: How to revert everything but current working head on to a previous commit

In git I already ran git add -u && git commit -a --amend to my working changes. I did not push the new commit to origin. I now found some previous git revision broke the build.

I want to keep my new commit, but go back to the last known 'good' git revision: say 04c06eb2acf154ba0e7f4e27044d1dffa6a42473.

I could run git reset --hard 04c06eb2acf154ba0e7f4e27044d1dffa6a42473 but that would lose my current revision

I also can't use git rebase -i HEAD~100 because the last good branch was a long time ago.

What is the best way to achieved my desired result?

Upvotes: 2

Views: 97

Answers (1)

Zombo
Zombo

Reputation: 1

I would just "back up" your last commit with

git format-patch -1

then undo what "broke" the build. After this you might need to manually apply the patch file, but you won't have lost anything.

Upvotes: 1

Related Questions