Categories
Fixing Stuff Laravel Samuel

stop tracking changes to a file in Sourcetree

Came across an annoying issue the past couple times I tried pushing commits to the remote repo on a current project. My local machine has a “nesting” error when serving this project locally that that I wrote about fixing in a previous post. Well now the issue was when I went to commit some new code it wanted to commit the bootstrap auto loader file, which of course I did not want committed to the repo since this is only a problem on my local machine.

So step 1 opened the .gitignore file and added bootstrap/autoloader.php to it…… and nothing. Source tree still kept trying to force me to merge in the change to the file. I then tried “stop tracking this file” in source tree by right clicking on it and selecting the stop tracking option. Still nothing. So then tried restarting source tree, pulling down ect… all various things to try and get sourcetree to stop tracking the file to no avail. So finally went searching for a git command that would force sourcetree to ignore the file and came upon:

git update-index --assume-unchanged file.filename

To run this I simply opened up gitbash, which we covered installing on windows in a previous post. So open up gitbash, cd to boostrap, then run our handy new command: git update-index –assume-unchanged file.filename

Viola the next time I opened source tree the file was no longer hanging in the uncommitted changes :). If you were running into a similar issue hopefully this simple git command will help you out too!

—update—
If we need to stop tracking an entire directory use:

git rm -r --cached path_to_your_folder/