Git ignores files that are not in gitignore

I have a git repository that ignores image files, as well as several other files, but in my .gitignore file it ignores the config.php . Is there some kind of global ignoring file somewhere that I cannot find? I must specify the files to add them now, and this gives me this warning:

The following paths are ignored by one of your .gitignore files.

The contents of my ~/.gitconfig file is just my email address.

+58
git gitignore
Feb 24 '12 at 18:56
source share
13 answers

Check this:

  • You searched for other .gitignore files, as there may be many.

  • Also, look at REPO / .git / config to see if there is anything.

  • Exclude Repo Local rules for each repo can be added to the .git / info / exclude file in your repo. These rules are not passed from the repo, so they are not passed to others. This method can be used for locally generated files that you do not expect from other users, such as files created by your editor.

+28
Feb 24 2018-12-12T00:
source share
β€” -

git check-ignore

Use git check-ignore to debug your gitignore file (exclude files).

For example:

 $ git check-ignore -v config.php .gitignore:2:src config.php 

The above matching pattern information (if any) for each given path name (including string).

So, perhaps your file extension is not ignored, but the entire directory.

Return format:

 <source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname> 

Or use the following command to print .gitignore in the HOME user folder and repository folder:

cat ~/.gitignore "$(git rev-parse --show-toplevel)"/.gitignore "$(git rev-parse --show-toplevel)"/.git/info/exclude

Alternatively, use git add -f , which allows you to add otherwise ignored files.

See man gitignore , man git-check-ignore more details.

Syntax

git check-ignore [options] pathname ...

git check-ignore [options] --stdin

+84
Mar 07 '15 at 19:12
source share

It would be nice to know that your git configuration may contain the core.excludesfile file, which is the path to the file with additional templates that are ignored. You can find out if you have such a configuration by running (in the problematic git repo):

 git config core.excludesfile 

If it prints the file path, see additional information about the contents of this file.

In my case, I installed git through an old version of boxen , which ignored the "Icon?" Template. which in my case gave me the warning mentioned in this question for the icons in the folder (I'm on a case-insensitive file system that the icons are Icon icons).

+44
Sep 09 '13 at 17:23
source share

I had the same problem: with this error, the git directory was ignored:

 ➭ git add app/views/admin/tags/ The following paths are ignored by one of your .gitignore files: app/views/admin/tags Use -f if you really want to add them. fatal: no files added 

It finally turned out that my problem was in my line ~/.gitignore_global :

 TAGS 

which corresponded to the path app/views/admin/tags . I fixed it by adding a leading slash to the global gitignore file

 /TAGS 

and git started tracking my directory again.

+19
Mar 10 '13 at 21:31
source share

For me, I accidentally had a wildcard in the ~ / .gitignore_global file. Maybe check there?

+4
Nov 20 '15 at 19:05
source share

Another thing: I had directory B with my own .git repository nested in my project directory A (but not as a submodule). I made some changes to B and wanted to do this in the bonafide submodule. I believe that git A automatically ignored B because it contained its own repository (see git Nested Repositories Without Submodules? ). I renamed folder B and tried to clone it again as a submodule, and this led me to the erroneous error message "ignored by .gitignore message". The solution was to remove .git from B.

+3
Sep 22 '13 at 23:46
source share

I had the same problem as you. The only answer you received lists several places to check, but none of them solved the problem for me, and from your comment I also don’t think for you. I did not have OTHER .gitignore files hidden below in the directory tree; nothing in .git / config; nothing in .git / ingore / exclude

If you still have a problem, check this answer . He solved the problem for me

Basically, check the ~ / .gitignore file. The mine was called ~ / .gitignore_global. I don’t know when it was created ( I certainly didn’t), but I tried a ton of another git installation when I first installed, so there must be one of them.

Hope his answer helps you!

+2
Jan 20 '13 at 16:13
source share

Another reason for getting this error message from git is when the git submodule add command was executed when the previous git command crashed and left a lock file (this could happen, for example, when using custom scripts that include git commands and you did not notice a failure).

If instead you run the git commit command, but none of the conditions has changed ( git submodule add will continue to scream that your .gitignore files will be to blame), you will see another error report instead:

 $ git commit -a fatal: Unable to create '..../.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue. 

and really removes the lock file:

 rm .git/index.lock 

fixes the problem. (This happens with git version 2.1.0.9736. It may be fixed in future git releases.)

+1
Dec 23 '14 at 6:11
source share

Also check out ~/.gitignore and ~/.gitignore_global , which can be created by some Git clients (e.g. Atlassian SourceTree on Mac OS X).

0
Mar 06 '15 at 6:14
source share

Make sure you have permission to this folder. I just ran into this, and this happened because the folder belonged to the www-data user, and not to the user to whom I was connected to the terminal.

0
Mar 30 '15 at 19:58
source share

Make sure the .gitignore file .gitignore not ignoring itself. A common mistake is to add the rule * to the .gitignore file to ignore each file in the current folder. The solution to this is to add an exception to .gitignore :

 * !.gitignore 

Thus, all files in the directory will be ignored except .gitignore .

0
May 04 '15 at 13:08
source share

In my case, it was a forward slash in my path causing the problem ...

Does not work

 /srv/bootstrap/ 

Work

 srv/bootstrap/ 
0
Oct 23 '15 at 0:46
source share

One more thing: if the directory you are in requires root access to write or execute, make sure that you are the root user. I really had a weird error when I tried to add a submodule and git kept complaining that the path I cloned to was ignored by the git ignore file. Then I switched to the root user, ran the submodule again, and there were no problems.

0
Jul 26 '16 at 13:36
source share



All Articles