I have a git tree with a lot of commits and a lot of files. Now, I want to revert specific commits that touch a file only. To explain:
> git init
Initiali
You can use git revert with the --no-commit option. In your example:
$ git revert --no-commit b49eb8e 1d8b062
# Files that were modified in those 2 commits will be changed in your working directory
# If any of those 2 commits had changed the file 'a' then you could discard the revert for it:
$ git checkout a
$ git commit -a -m "Revert commits b49eb8e and 1d8b062"
If you don't provide a commit message then a prepared message will be available when the commit message editor is started.
If you omit the --no-commit option then the changes in the commits you specify will be reverted. This is achieved by applying the reverse of the changes in the specified commits and committing that. This results in a new commit, both the original and the reverted commit will be in the history of your repository.