What does the "Remove" button in SourceTree do from the Branch screen

In SourceTree, if I'm on the branch screen and I click the Remove button, I get a message that says

"Confirm Remove Modified or Untracked Files?

The following files contain changes or information which is not in source control, and will be irretrievably lost if you remove them:


This is definitely untrue, as foo/code.php has been add and committed to my repo.

It seems to select files modified in my last commit to display the message about and to then remove them as if I had done a git rm command on them if I click Ok.


Is this the intended purpose of this button - to remove all the files you modified in your last commit?  What would be the logic of this?  I would intuitively expect the Remove button to take me to a screen where I could select a file(s) to remove.


8 answers

1 accepted

0 votes
Accepted answer

so it's clearly doing an rm on "aaa/aardvark.php" in this example. But I didn't select that file. Why has it decided that when I click "remove" from the branch screen without selecting any specific files, that "aaa/aardvark.php" is the file that I want to remove? Especially when, as in the previous example, that file is not even in the repository anymore. It seems like it's selecting the most recently modified file. I don't understand what the logic of that is. Is there a use case where you would frequently want to remove the most recently modified file?

Even if that's the case, then the button should be more descriptively labeled. From the "file status" screen (which is also the "commit" screen, I can use the "Remove" button in a intuitive way to remove selected files. But on the branch screen (which is kind of the "main" or default screen), no files are particularly selected. I mean, I guess one is, if I look down at the bit of the screen showing diffs. I suppose I've answered my own question there.

Ok, I think I get it now. But it strikes me as a bad UI. If I'm looking at the top part of the screen at my commits and branches and such and now looking at the diffs, which happen to to be showing one particular file by default because I haven't selected any others, I'm really not thinking in terms of a file being selected and the buttons on the top tool bar performing operations on a particular file. This is even more true because if you look at the file selector in the lower left corner, the folder appears hi-lighted but the file doesn't. It would, of course, if I clicked on it, but I haven't yet in this example. It's just picked one file to display the detailed diff of by default.

Unintutive that if I hit "remove" from that point the file it's picked to show the detailed diff of is the one it assumes I'm wanting to remove. And even still, it's erroneously displaying the warning about changes being lost.

Yeah, sounds like we're on the same page. Additional comments: The button is labelled "Remove" because that is the Git command it runs. Git doesn't use "remove" in any other context I know of (it "deletes" or "resets" branches, "reverses" commits, and "discards" uncommitted modifications). I definitely agree that the usage of those buttons when viewing commits in the log is confusing, but having them available when you are viewing "uncommitted chages" at the top of the log is useful. You might consider submitting a feature request to jira.atlassian.com if you have a complete, concrete suggestion for how the UI could be improved.

actually it doesn't seem to do this to all files modified in the last commit. I'm not totally sure how its selecting the file that it does the "git rm" on.

It seems like maybe it removes the last file modified? or something?

It would be helpful if you could post a screenshot. Not really clear which remove option you are talking about.

Is it possible that you added and committed foo/code.php, then made additional, uncommitted modifications to it?

@Balazs: This big button that says "Remove"

@Seth: No.  And even if I had, what process is the software using to determine which file to remove?


Screen Shot 2015-03-24 at 9.33.21 AM.png

Amusingly, after committing the (somewhat arbitrary) removal that it chose to make, if I click the "Remove" button again, it attempts to remove the same (no longer present) file and gives this error message:


Screen Shot 2015-03-24 at 9.37.56 AM.png

The Remove button does not remove a branch or a commit, it removes a selected file or files. In this case, you're trying to remove either aaa/aardvark.php, or all the files that are being displayed under aaa/ (which in the screenshot is just aardvark.php). I don't use tree view, so I don't know the ramifications of having a folder selected.

If you want to delete a branch, you should right-click the branch in the left panel, or do whatever keyboard acrobatics mac users have to do to get a context menu if your mouse still only has one button.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,106 views 4 2
Read article

Atlassian User Groups

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!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you