简体   繁体   中英

All new files I add are ignored by git

I have a project that uses git for its source control and I use SmartGit as the GUI.

Recently when adding new files to the project they're being ignored by git (this has only started happening in the last week or so before that it was fine).

So if I add a new file into the hierarchy it doesn't show up in the SmartGit GUI.

If I type git status into git then nothing comes up.

If I type git status --ignored into git then it lists the file I had added.

If I type git add -f filename then it adds the file and it shows up in SmartGit.

I've checked my .gitignore file and it has nothing unusual in it.

I don't have a global .gitignore . I do have an exclude file but it is referencing a subdirectory and had been working fine long before this problem showed up.

Any ideas why git should think all new files are ignored even when they aren't referenced in a .gitignore file?

That's the intended behaviour. New files are untracked by git unless and until you use 'git add' which will bring them into version control.

If you create several new files, you can add them all with:

git add -A

anything that's covered by a .gitignore entry will be excluded.

I don't know how and when , but in my case I had the whole directory added to .gitignore. Use:

git check-ignore -v path

To check for ignored files and directories. More info at: Git is ignoring files that aren't in gitignore

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM