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.

remove file from commit 1

The problem comes when i commit both "file2" and "file3". And suppose that file3 is the file i don't want to commit

remove file from commit 2

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

remove file from commit 3

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.

remove file from commit 4

Let's unstage file (files) you don't want to commit.

In this case, i remove "file3"

remove file from commit 5

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.



Long Trương

Hi, i'm Long. Welcome to my personal blog. Hope that you can findout something helpful...


sikis izle · 15 November, 2020 at 22:06

Remarkable! Its in fact awesome post, I have got much clear idea concerning from this post. Nanette Hillier Mosera

film · 26 November, 2020 at 04:49

Absolute enjoyable information that you have remarked, thanks for putting up. Eleen Alberik Crissy

film · 26 November, 2020 at 18:40

I am truly thankful to the owner of this website who has shared this impressive post at at this time. Carlita Fields Boggers

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *