How can I remove a file from my last commit, but keep everything else? Please note that I haven’t yet pushed anything to a remote repository, so I just have to do this locally.
My workflow:
- Edit a few files
- Accidentally create a new file named
untitled.txt - Commit everything
- Notice the unwanted
untitled.txtfile - Delete it
- ???
- Live happily ever after
Thanks in advance!
You can easily change whatever you like in your last commit (messages, files, etc) with
git commit --amend.So you would do something like this: