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?
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 .
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.
. 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With