Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Stop Tracking and Discard File in git SourceTree

I wanted to know what the difference is between discarding a file and and stop tracking a file in git using source-tree. If I deleted a file in my updated code and I want that file deleted on the repository too should I mark it as stop tracking or should I discard it during the commit process

like image 609
MistyD Avatar asked Jun 16 '15 00:06

MistyD


People also ask

What is stop tracking in SourceTree?

suo file storing Visual Studio settings that you decide shouldn't have been in source control) but remove it from the repository, you should use Stop Tracking. After this, if you see the file listed in Unstaged files, you can use right-click > Ignore... in SourceTree to update your .

What is the use of discard in SourceTree?

On SourceTree for Windows, right click the files you want to discard (in the Working Copy Changes list), and choose Discard. On git, you'd simply do: git reset --hard to discard changes made to versioned files; git clean -xdf to erase new (untracked) files, including ignored ones (the x option).

What is git stop tracking file?

Using git rm to Stop Tracking Files in Git This will remove the file or folder, as specified, from tracking (i.e.) remove it from the index; but will not delete the file from the filesystem.


2 Answers

The one detail not covered by the first answer is that Stop Tracking does not delete the local file. It only removes it from source control.

  1. If you want to keep the file locally (maybe it's a .suo file storing Visual Studio settings that you decide shouldn't have been in source control) but remove it from the repository, you should use Stop Tracking. After this, if you see the file listed in Unstaged files, you can use right-click > Ignore... in SourceTree to update your .gitignore file to ignore the file in future.
  2. If you want to delete your file both locally and in the repository, you should use Remove. (to use the SourceTree term)
  3. Finally, if you only want to revert your local changes without
    changing the repository at all, use Discard.
like image 142
Ken Lyon Avatar answered Sep 21 '22 15:09

Ken Lyon


In SourceTree, selecting "discard" on a file just throws away your local changes; stop tracking removes it from the repository. However, as long as you have deleted the file on your local drive, and you can see that deletion in the "Staged Files" section of SourceTree, it will be deleted in the repository as well when you commit.

like image 25
David Deutsch Avatar answered Sep 21 '22 15:09

David Deutsch