It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Cannot ignore

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

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.

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

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

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.

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.

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

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'.

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

Like igor90007 NA likes this

This worked for me. Thanks!

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

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

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

Like # people like this

Same here i cannot ignore files from submenu

Like igor90007 NA likes this

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>)

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

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

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.

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.

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).

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

What's the point of that?

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

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Agile

Webinar: Dean Leffingwell and Steve Elliot present on SAFe 5.0, come ask Dean and Steve questions!

...steemed Steve Elliot (head of product for Jira Align). Agenda: What’s new or changed in SAFe 5.0: Introduction of OKRs Essential SAFe How to achieve true business a...

126 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you