0

I accidentally added a file to my last commit that really shouldn't be part of the previous comment, it should be part of my next commit instead.

Is there a way to remove a file from my last commit and put it back in the unstaged area?

Please note that only one file needs to be removed from the last commit.

fs_tigre
  • 10,650
  • 13
  • 73
  • 146
  • 2
    I don't know about Git-Tower, but in raw Git, you have to kick your last commit "off the end of the branch" (this is completely safe when you just made it and have not given it to anyone else) and then redo the commit the way you wanted. You'd use `git reset --soft HEAD^` to do the kick-commit-off thing, then a `git restore --staged ` to get the file state back to unstaged, then re-commit and you're done. – torek Aug 18 '22 at 16:11
  • `git reset --soft HEAD^` did the trick. I first ran `git reset --soft HEAD^` and then just deselected the file to unstage it and finally recommitted. I didn't have to do the `restore --staged` since the UI allows the user to do that by selecting/deselecting files. Thanks a lot. – fs_tigre Aug 19 '22 at 13:47

1 Answers1

0

Yes, you can easily do this with Tower, using Interactive Rebase. Simply right-click on the commit and select Edit <revision>. All committed files will be placed back in your Working Copy. You can then commit the files separately as required.

Tower has extensive Help documentation available, which might be helpful when you are looking for a specific feature: https://www.git-tower.com/help/guides/commit-history/interactive-rebase/mac