2

My last three commits are the following:

commit 440badcebc459fd6e0aec6df3acd68bbfe797f14
Author: Michael J <michael@gmail.com>
Date:   Sat Oct 12 02:27:20 2013 +0200

    Add config.assets.initialize_on_precompile = false

commit 4ca67cdeeab3290bc3fb3349d6c1b606ed61d5f8
Author: Michael J <michael@gmail.com>
Date:   Sat Oct 12 02:22:04 2013 +0200

    Added a bogus file to shared.

commit 0dd36b5705598ccb7878c5eee9e09f8e1a75296e
Author: Michael J <michael@gmail.com>
Date:   Sat Oct 12 02:17:24 2013 +0200

    Change js structure.

I want to revert those three commits with the method mentioned in a SO answer, i.e. by

"... create a new commit which reverts changes that you want to get rid of ..."

The docs gives an example on how this could look like:

git revert -n master~5..master~2

I'm unsure though what to put as an argument: master-something, HEAD-something, the commit message or the commit id?

What should I put as a an argument after -n/--no-commit given the the example commits above?

Community
  • 1
  • 1
Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232

1 Answers1

2

This will revert the changes done by commits from the 3rd last commit in master (included) to the 1st last commit in master (included):

git revert -n master~3..master
Agis
  • 32,639
  • 3
  • 73
  • 81
  • 2
    This is probably the best way, at least if you're on `master` (using `HEAD~3..HEAD` would be branch-agnostic), but since you already have the commit SHA1s from the `git log output`, you could also `git revert -n 0dd36b..440bad` – twalberg Oct 15 '13 at 15:52