Reputation: 8499
I am using SourceTree for my GIT repositories.
Today I need to ignore some files; when I added these files to ignore list from SourceTree's "Ignore file" menu and check local .gitignore file, the ignored files are not listed there. Instead these are listed in the global .gitignore.
How can I get SourceTree to add the files to the repository-specific .gitignore?
Upvotes: 30
Views: 82036
Reputation: 425
In my case, at some point in time, Sourcetree started using the gitconfig from C:\Program Files\Git\mingw64\etc\gitconfig instead of using C:\Users\yourUser.gitconfig.
Once I added the following line in this gitconfig, it resolved my issue on Sourcetree:
[core]
safecrlf = false
excludesfile = C:\\Users\\<YOUR_USER>\\Documents\\gitignore_global.txt
Please note that on my side the global ignore setting from Tools/Option/Git/ does not seemed to be considered by Sourcetree, therefore I don't even need to change it.
Upvotes: 2
Reputation: 6922
Easiest way to edit the individual, is right click the file. Click Ignore and select the option to ignore just in this repository then you will see a new file called .gitignore in the list.
If you have accidentally already added them to the list. You can delete them by going to Sourcetree - > Preferences -> Git menu option. See below.
As a quick tip - I find that github has a great selection of starter github ignore files which I find really useful to start a new project
Eg: https://github.com/github/gitignore
Upvotes: 34
Reputation: 3166
I had the opposite issue, local worked but global did not work, for that you also need to create the global ignore file by running the command line
git config --global core.excludesfile ~/.gitignore_global
Else source tree will not save this in the preferences.
Then follow the acanby solution.
Upvotes: -1
Reputation: 2993
When you choose to ignore a file that is modified etc, SourceTree will bring up the following dialogue:
Instead of choosing the "global ignore list", select the "this repository only" option.
Upvotes: 31