alex440
alex440

Reputation: 1657

"git add ." adds ignored files

I have a gitignore file

~\.gitignore_global 

with several patterns. I added a directory to my source, and run

git add .

Then when I run

git status

it does show me that the old ignored files are still untracked, but the new files with the ignored extensions would be committed?

this is my gitignore file:

*.obj 
*.cache
*.tlog
*.resources
*.pdb
*.bin
*.user

Why is it so and what can be done to automatically ignore all the files I want to ignore on this and subsequent commits.

=======================================================================

EDIT:

The problem solved by installing a SourceTree client, which managed all the ignore stuff for me :)

Upvotes: 0

Views: 2760

Answers (3)

alex440
alex440

Reputation: 1657

The problem solved by installing a SourceTree client, which managed all the ignore stuff for me :)

Made a commit in 2 minutes, including initial options.

I think from now on I stick to the client...

Upvotes: 1

Sailesh
Sailesh

Reputation: 26197

If you add a new entry into your gitignore which was earlier tracked, the file remains tracked. You have to explicitly untrack it.

git rm --cached filename

Then, if you do git add ., you will not see the ignored files.

Upvotes: 4

Dogbert
Dogbert

Reputation: 222118

You need to set the global gitignore config in ~/.gitconfig

You can run this to do that automatically:

git config --global core.excludesfile ~/.gitignore_global

Upvotes: 2

Related Questions