I have committed a commit with 3 files in it. Now I want to amend that commit with only 2 of the 3 files in it, i.e. I want to remove 1 file from the commit.
Solution in Git GUI:
In "git gui", when selecting "Amend last commit", all the content of the commit gets listed in "Staged Changes" window, thus enabling the user to unstage files / lines before committing the new commit.
Problem in SourceTree:
When selecting "Amend latest commit" it does not list the content from the latest commit in the "Staged Changes" window, thus it is not possible to remove files / lines from the commit, only to add new files / lines to the commit.
Or am I missing some option?
Seth, the commit amend workflow in SourceTree would then be:
1) Reverse commit
2) Reset soft
3) Commit amend (where you unstage the unwanted file)
The commit amend workflow in "git gui" is:
1) Commit amend (where you unstage the unwanted file)
The simple reason is that in "git gui" all content from latest commit is listed in "Staged Changes" window, SourceTree does not list those.
This has 2 negative impacts (in my mind):
1) When you do a commit amend in SourceTree (even if you are just adding stuff, not removing anything) you can not see the full list of changes which you are about to commit, only what you have added/changed on top of your commit. You basically don't know what you are committing, (unless you "reverse" and "reset" each time before a commit amend).
2) If you want to remove a file or change from a commit by amending it, you have to do a "reverse" and "reset" first. Or, click "Terminal" and fire up "git gui" ...
But yes, you have answered my question (though I already knew how to do this, was just puzzled about the fact that it was such a cumbersome process in SurceTree when I'm used to an easy one-step process in "git gui").
Just my 2 cent ... and hoping to see this native Git feature added to the SourceTree backlog ;o)
You don't need to reverse the old commit. If you view the previous commit, you can reverse just specific chunks. These reversions are written to your working copy, not automatically committed.
In terms of the first negative impact, I'd rather see just what I'm changing from the previous commit, rather than a compliation of changes from both my working copy and the commit that's being amended. I guess that just comes down to personal preference.
Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot