Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot ignore

darthness December 20, 2011

HI,

I cloned a new github repo, and i've never had problems ignoring files before. i have the following .gitignore file:

.DS_Store
.settings
.project
.buildpath
components/invoice/lead
var/file
var/decline
config.php

however, sourcetree ignores this .gitignore file and i can't even ignore files from source tree. What could be wrong?

greetings

10 answers

1 accepted

1 vote
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2011

The .gitignore behaviour in SourceTree is still 100% implemented by Git, SourceTree just provides some assistance in adding items to the ignore files. So SourceTree itself can't avoid using the .gitignore files, this is just git. You can ignore files from SourceTree, just right-click and select Ignore (although right now you can only do this on single files, but can expand the match pattern in the resulting dialog to mean the parent folder or a wildcard).

If this is the global gitignore, check Preferences > Git to make sure the correct path to this is being used. If it's the repo-specific one then I don't know why that's not working if it's called '.gitignore', as I say it's only Git that can pick this up, not SourceTree, and mine are working fine.

vietxitin December 14, 2015

I can ignore new file create by me, but file i checkout from other user, i edit and can't ignore this file. I see this bug for along time but you didn't fix, have more people have same problem like me.

Like igor90007 NA likes this
Francisco De La Iglesia December 28, 2016

No, this is not working for years and still a pain in the ass. It is a really annoying bug. If a file is already tracked it is IMPOSSIBLE to make SourceTree to ignore this file. I have lost almost two days of work trying to solve this issue and it is not possible unless you manually un-track the files from the command line with Git.

Like igor90007 NA likes this
Fabian Holmberg February 6, 2017

Does not work for me either. The option to ignore is never available, whether you stop tracking the file or not.

Further to this, Source Tree pertinently ignores all my attempts to point it to a global .gitignore file.

As i'm using Visual Studio, I have a .gitignore file with content that can be found in the following link:

https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

I have pointed to the .gitignore file with the above content from 3 locations in SourceTree:

1) settings->advanced
2) tools->options git and
3) tools->options mercurial.

The .gitignore file is all but ignored, and every time I compile in Visual Studio the temporary files that are on the ignore list in my .gitignore file still show up in the unstaged files in source tree. Me and my collegues really want to use SourceTree with git but this is making it all but impossible.

Steven Cinquegrana April 18, 2017

Yep, same here. 'Ignore' is never available from the context menu. You can 'Stop tracking' ok (and why would that be different to 'Ignore' anyway?)

Not a deal breaker for me but still, worth fixing, I think.

mccunet February 1, 2019

I've seen this before and I see it most often with .suo files that don't get ignored even though they are included in the .gitignore file.
But I think it's because I cloned a project before setting my global .gitignore file in the SourceTree GIT options.
So I think what happens is that I save something in Visual Studio and it updates the .suo file and I end up inadvertently including the .suo file in a commit.
I then realize later that I don't have the .gitignore defined in SourceTree because I'm seeing the .suo file show up under "Unstaged files".
So now I go and define my .gitignore in the SourceTree options but it still shows up under "Unstaged files" after saving my project in Visual Studio.
I think my mistake is that I saved the .suo into my .git repo before setting the .gitignore preference so once I've told GIT to track it, GIT can't ignore the .suo even though I've now set the .gitignore option.
To test this theory, since I now had the .gitignore set in SourceTree, I just cloned the project down again to a new location and then saved the project multiple times in Visual Studio and in this scenario I no longer see the .suo under "Unstaged files".
So I have to remember to not commit anything before defining the .gitignore option.
Alternatively, if I've committed before defining the .gitignore file, I can set the .gitignore location and then go back and remove the .suo file from the GIT repo.
To do this, just right-click the file and select "Stop Tracking". This stages a remove operation which has to be committed for SourceTree to stop tracking the file.
There's a good discussion of this here:
https://stackoverflow.com/questions/936249/how-to-stop-tracking-and-ignore-changes-to-a-file-in-git

Like igor90007 NA likes this
4 votes
bobmulder October 23, 2014

First right-click on a file and press 'Stop Tracking'.

The file will stay in the 'Unstaged Files'-list. 

Than right-click again and press 'Ignore'.

Francisco De La Iglesia December 28, 2016

No you can not. Within SourceTree UX is NOT possible.

Like igor90007 NA likes this
borja_lopez_altarriba January 18, 2017

This worked for me. Thanks!

Fabian Holmberg February 6, 2017

Does not work for me either.  See my reply to the accepted answer above.

2 votes
Psijic November 6, 2013

Hello, I can't ignore files from SourceTree submenu - it's always disabled

epataky January 1, 2014

I cannot ignore files sometimes .. very frustrating .. what can i do?

Like # people like this
Eduardo Nunes Pereira July 14, 2015

Same here i cannot ignore files from submenu

Like igor90007 NA likes this
1 vote
epataky January 1, 2014

I cannot ignore files sometimes .. very frustrating .. what can i do?

1 vote
Joseph Lombrozo July 15, 2013

I had a similar problem, but it turned out that my gitignore_global.txt was in the wrong place. I had to move it to %userprofile%\.git\gitignore_global.txt and then it started working (%userprofile% usually points to c:\users\<username>)

mdolnik November 10, 2015

This, as well as pointing sourcetree to [%userprofile%\.git\gitignore_global.txt] in the Tools>Options>git> Global ignore list... helped fix my global ignore file issues

0 votes
Deleted user February 24, 2016

My impression is that files with name starting with '.' (dot) (for example .classpath) will show up in 'Unstaged files' (having set Show only: modified)

EVEN IF these files are listed in .gitignore

 

0 votes
MikeP May 13, 2014

Yeah why is the "ignore" menu option in SourceTree always greyed out?

What's the point of that?

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2012

Please see the answer to the original question - SourceTree actually just calls 'git status' under the surface and relies on its own behaviour for ignored files, therefore I can't understand this. If possible, please provide an example repository so we can investigate further (if you don't want to post it publicly, please raise an issue at https://support.atlassian.com where you can do it privately).

0 votes
Danail Nachev July 25, 2012

Version: 1.5.1

Git: System 1.7.10

I have roughly the following .gitignore file:

target/

.project

.classpath

If I execute:

git status

It correctly shows only a single file as changed. However, SourceTree shows many files in the Maven's folders as untracked and ready for adding. If I select Show Ignored, it shows only the .classpath and .project files as ignored. However, all files in the target/ folders are showed as pending.

0 votes
Danail Nachev July 25, 2012

Version: 1.5.1

Git: System 1.7.10

I have roughly the following .gitignore file:

target/

.project

.classpath

If I execute:

git status

It correctly shows only a single file as changed. However, SourceTree shows many files in the Maven's folders as untracked and ready for adding. If I select Show Ignored, it shows only the .classpath and .project files as ignored. However, all files in the target/ folders are showed as pending.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events