It is possible in GitKraken to revert changes of a single file to an earlier commit instead of reverting an entire commit?
To undo changes associated with a specific commit, developers should use the git revert command. To undo every change that has happened since a given commit occurred, use git reset.
To revert a commit with GitKraken, simply right-click on any commit from the central graph and select Revert commit from the context menu.
To discard changes, select the //WIP node to summon the icon. This option will discard all changes or discard any multi-selected files.
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.
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
.
You can accomplish this in the GitKraken UI, but it's a little roundabout:
This should leave you with only an add for the one file you wanted to restore. Commit that, and now you've got your one file back.
Note that this can work across numerous commits, not just one... but since it's going to have to roll back everything from all of those commits, and then discard all of the rollbacks (except one) it can be quite slow if involves massive changes. In situations like this, it is probably better to use the git CI as suggested in kowsky's answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With