Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore whitelist * not working correctly

Tags:

git

I have attempted to create a whitelist in my .gitignore file as such:

#Ignore everything
*
#Don't ignore directories, so we can recurse into them
!*/
#Don't ignore files
!*/docs
#!cmd_mux.vhd
!.gitignore
!*.vhd
!*.v
!*.fdo
!*.xise

However, Git is still ignoring cmd_mux.vhd. If I uncomment the line that directly specifies cmd_mux.vhd, it works fine.

What's going on here?

like image 516
joshua-philpott Avatar asked Jul 23 '13 19:07

joshua-philpott


People also ask

Why isn't my Gitignore working?

The Solution To resolve the problem remove from the repository the tracked files contained in the . gitignore file. To achieve this use “git rm” to remove and untrack all the files in the repository, then use “git add” to re-add all the files (the files contained in the .

Why is git ignore not ignoring?

gitignore file isn't ignoring your files and directories. . gitignore just ignores files that have not yet been added to the repository. If you have already git added certain files, their modifications will be tracked.

How do I use wildcards in Gitignore?

. gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.

How do I add ignored files to Gitignore?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.


1 Answers

You could try the check-ignore command to debug the ignore process:

$ git check-ignore cmd_mux.vhd -v
.gitignore:7:!cmd_mux.vhd

It should print out the pattern (whith the enclosing file) that affects the ignore status of your file.

like image 66
Alessandro Avatar answered Sep 24 '22 11:09

Alessandro