Read more

Git: Revert one or more commits

Tobias Kraze
August 31, 2010Software engineer at makandra GmbH

Reverting a commit means creating a new commit that undoes the old changes.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Imagine the following commit history:

* commit_sha3 [Story-ID 1] Fixup for my feature 
* commit_sha2 [Story-ID 5] Other feature
* commit_sha1 [Story-ID 1] My feature 

You can revert a single commit using the following syntax:

git revert commit_sha2

To revert changes that are split across multiple commits, use the --no-commit flag.

git revert --no-commit commit_sha3
git revert --no-commit commit_sha1
git commit -m "Revert Story 1"
Posted by Tobias Kraze to makandra dev (2010-08-31 09:44)