Can I do a partial revert in GIT

git

Solution

You can revert the commit without creating a new one by adding the `--no-commit` option. This leaves all the reverted files in the staging area.

From there, I'd perform a mixed reset (the default for reset) to un-stage the files, and add in the changes I really wanted. Then, commit, (you can add and commit more files if you want multiple commits), and finally, checkout the current directory to wipe out any uncommitted and un-staged modifications resulting from the `revert`. For an example workflow:

git revert <sha-of-bad-commit> --no-commit
git reset   # This gets them out of the staging area

# ...edit bad file to look like it should, if necessary

git add <bad-file>
git commit
git checkout . # This wipes all the undesired reverts still hanging around in the working copy

Problem

Is it possible to revert only a single file or certain changes in a file in multi file commit? Full story I committed a bunch of files. A number of commits later someone who will remain nameless (JACK!!!) copied a file into his repository and committed several files, overwriting some of the changes I did. I want to revert the one file that got clobbered or better yet, go in and revert two changes in that file. This will have to be a separate revert commit since it was pulled and pushed.

Original source