What does the "Remove" button in SourceTree do from the Branch screen
Asked by Tim Crall:

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:   
foo/code.php"

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.


Answers:
author: Tim Crall
body: 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.

comments: author: Seth
body: 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.


author: Seth
body: 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.


author: Tim Crall
body: 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  
[](https://community.atlassian.com/t5/Sourcetree-questions/What-does-the-quot-Remove-quot-button-in-SourceTree-do-from-the/qaq-p/125747?attachment-id=3326){#link_116a79a8344204}  
[](/tnckb94959/attachments/tnckb94959/sourcetree-questions/3738/1/Screen%20Shot%202015-03-24%20at%209.37.56%20AM.png){#display_116a79a8344204_0}


author: Tim Crall
body: @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  
[](https://community.atlassian.com/t5/Sourcetree-questions/What-does-the-quot-Remove-quot-button-in-SourceTree-do-from-the/qaq-p/125747?attachment-id=12473){#link_116a79ae0652a6}  
[](/tnckb94959/attachments/tnckb94959/sourcetree-questions/3737/1/Screen%20Shot%202015-03-24%20at%209.33.21%20AM.png){#display_116a79ae0652a6_0}


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


author: Bal?zs Szakm?ry
body: It would be helpful if you could post a screenshot. Not really clear which remove option you are talking about.


author: Tim Crall
body: It seems like maybe it removes the last file modified? or something?


author: Tim Crall
body: 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.