Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't gitignore work in this case?

Tags:

git

gitignore

I have two files I wish to ignore:

  • .idea/workspace.xml
  • someapp/src/.idea/workspace.xml

I thought adding this single rule to .gitignore will suffice:

.idea/workspace.xml

But it only catches the top-level .idea/workspace.xml (git status shows someapp/src/.idea/workspace.xml as untracked).

I also tried **/.idea/workspace.xml, but this doesn't work at all. Help?

like image 328
ripper234 Avatar asked Nov 16 '11 17:11

ripper234


People also ask

Is Gitignore file ignored?

gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories. To create a local .

Why is my Gitignore file not working?

Some times, even if you haven't added some files to the repository, git seems to monitor them even after you add them to the . gitignore file. This is a caching issue that can occur and to fix it, you need to clear your cache.

How do I ignore an already committed file in git?

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

This has changed in git 1.8.4

Use of platform fnmatch(3) function (many places like pathspec matching, .gitignore and .gitattributes) have been replaced with wildmatch, allowing "foo/**/bar" to match "foo/bar", "foo/a/bar", etc.

**/.idea/workspace.xml should work now in this example.

like image 147
eddiegroves Avatar answered Nov 06 '22 01:11

eddiegroves