how to recovery the file to commit after stop track it in sourcetree?

in sourcetree, I stop tracked a file yestoday, but I want to commit it to repository. how can i do it? please help me 

3 answers

This widget could not be displayed.

What exactly do you mean by "I stop tracked a file"?

This widget could not be displayed.

Execute a command to stop tracing a file

This widget could not be displayed.

(Assuming you right-clicked on a file and selected the "Stop tracking" option.)

This command stages a change that deletes the file (line with a red minus in the beginning in the pending changes), but leaves the file intact on your disk (it shows as an untracked file):

image2015-5-22 11:10:26.png

You can undo this by right-clicking on the line with the red minus and selecting "Discard".

EDIT: once this deletion is committed, this is how to undo it:

  1. Select the commit where you removed the file.
  2. On the bottom, right-click on the file name, select Log selected.
  3. In the Log window, select the last revision where the file was still there (probably the second commit from the top), right-click on it and select "reset to commit".
  4. The file now shows up as an uncommitted change, commit it.

I commit this red minus file to repository. I can't find "discard" option.

I edited the answer to show the recovery steps for this case as well.

I think in step 3 you want to "Reverse commit".

He does not necessarily want to revert the other changes in the commit.

True, but "reset to commit" will change the history, which will be a problem if he's pushed.

This reset is not that reset. :) It resets a file to a certain state, not the commit history to an earlier point.

Ah, not clear that you meant to right click on the FILE rather than the COMMIT: "select the last revision where the file was still there ... right click on it".

Step 3 happens in the file history window. (Opened in step 2.)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

877 views 2 3
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