Have you ever commit all file from your project. After that, you realize that threre is a file (or files) you are not ready to commit it. So, the problem is that you want to remove a file from last commit?
Here you can see in the image below. I have one commit and 2 new files.
The problem comes when i commit both "file2" and "file3". And suppose that file3 is the file i don't want to commit
Okey .Let's do some very simple stuff to remove "file3" from last commit.
NOTE: In this post, i use SourceTree. You can use other tool or use git command line
Step 1: Reset to last commit use "SOFT" option
Step 2: Remove file (files) you don't want to commit.
You can see i've comeback to last commit and new files still there.
Let's unstage file (files) you don't want to commit.
In this case, i remove "file3"
Step 3: Commit
You can now re-commit without files you don't want.
Please leave a comment to let me know that you successfully removed the unwanted files.
THANKS FOR READING MY POST!