Read more

Git: "Interactive reverts"

Tobias Kraze
November 11, 2010Software engineer at makandra GmbH

If you need to revert only parts of one or several commits the following workflow can help:

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

If you need to revert multiple changes, make a branch and squash it afterwards.

For every commit you need to revert, starting at the most recent, do:

git revert -n [COMMIT] #revert, but don't automatically commit
... #fix any conflicts
git reset #unstage all changes
git add -p #this will ask you for every change, whether you want to go through with the revert (i.e. "y" will revert, "n" will not; "?" for help)
git commit
git reset --hard #throw away all changes you did not want to revert
Posted by Tobias Kraze to makandra dev (2010-11-11 10:40)