Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to unstage files (from previous commit) when doing amend in SourceTree?

Christoffer Pettersson March 25, 2015

When I check "amend latest commit" in SourceTree, I would like to see all the files that were included in that commit in the "Staged files" area, so that I can easily exclude a file and then redo the commit.

Git GUI has this functionality.

 

Is it possible to unstage files (from previous commit) when doing amend in SourceTree?

3 answers

2 votes
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2015

Two options for removing those files:

1)You can delete them from your system, and stage the removal, or find the files in SourceTree and choose "Stop Tracking" if you want to keep them.

2) Reset to the previous commit, and re-commit (instead of amending).

Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2015

You should only do a reset if you haven't pushed the commit, though. A soft reset will move the branch pointer back without changing the working directory. You can then stage only those changes you want to commit, and commit again. This is almost certainly what Git GUI is really doing underneath the hood.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2015

True, if you've pushed the commit, you shouldn't be resetting OR amending. Both operations modify the history, which can give headaches to team members that have already fetched it.

Christoffer Pettersson March 26, 2015

Yea, this is prior to a push, but I still want to be able to "add" and "remove" from the latest commit. (Its a ways of working for me, I isually push to a temp-commit in my feature-branch and then add/remove changes from that until I am ready ^_^)

0 votes
Christoffer Pettersson March 26, 2015

Remove those files from the commit

0 votes
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2015

What are you hoping to achieve by unstaging? Are you wanting to remove those files, or just reverse changes made in them?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events