Reverting one file in GitKraken

Feofilakt picture Feofilakt · Apr 7, 2017 · Viewed 12.6k times · Source

It is possible in GitKraken to revert changes of a single file to an earlier commit instead of reverting an entire commit?

Answer

kowsky picture kowsky · Apr 7, 2017

Answer

A revert in the git-sense of it can only be performed on a commit. It introduces a new commit that exactly negates the reverted commits' changes. See here. GitKraken supports this: right click on a commit, Revert <branch> to this commit.

What you want to accomplish, however, can be done via git checkout. I do not think GitKraken supports this funtionality for a single file yet. You can, however, use the command line.

Reset single file via command line

git checkout <commit> <file>

Check out a previous version of a file. This turns the <file> that resides in the working directory into an exact copy of the one from <commit> and adds it to the staging area.

Documentation can be found here.

git checkout HEAD~1 <filename> will thus reset a single file to the commit before the current HEAD.