Search code examples
gitkraken

How can I amend a commit in GitKraken to unstage a file?


I just committed three files to Git (Class1.java, Class2.java, and Config.xml). Then I realized that I made a mistake, and didn't actually want Config.xml in that commit. Now I want to amend my commit and unstage the changes to Config.xml, so that the (amended) commit contains only the changes to Class1.java and Class2.java.

This is easy in Git Gui; select "Amend previous commit", and the "Staged Changes (Will Commit)" list shows me all three files that were changed in the previous commit. I can unstage Config.xml and commit.

But in GitKraken, when I check "Amend", it doesn't show me the three files from the previous commit; it just shows me a blank slate. There's no clear way to unstage one of the files from the commit I'm amending.

I know I can use the command line (or Git Gui). But is there any way, from GitKraken, to amend the previous commit and simply remove one file's changes from it?


Solution

  • Your observations are correct: You can't.

    There is no way to remove changes from a commit via amend at this time, as far as I know. You can only add other changes to the commit (which may of course nullify some of the changes you commited before). As you correctly observed, this is because GK does not show you the previous commit when you check Amend, you can only add your unstaged changes.

    A pure GK workaround would be a soft reset to the previous commit and a new commit only containing Class1.java and Class2.java. The result would be the same, since an amend would also create a new commit.