6

The problem:

I'm on OSX. I have a very small .gitignore file, and I even tried completely deleting the file. Nothing helps. Git doesn't see anything under my .idea directory for intellij.

At the very least I want to store .idea/runConfigurations/*. Worse than that, according to this post, all the files in that directory but 1 or 2 should be source controlled.

Is there an extra, hidden .gitignore setting somewhere I don't know about? Is there any way to search for and murder it if so?

Steps taken so far:

I manually added the most important ones with:

git add .idea/runConfigurations -f

Trying that without the -f gave:

The following paths are ignored by one of your .gitignore files:
.idea
Use -f if you really want to add them.

To reiterate: it gave that error even when I completely deleted my .gitignore file

Similar-but-unsolved thread:

After raking through SO I managed to find one other thread having the same problem. Unfortunately it got marked as answered even though the original poster replied that the problem remained unsolved. Regardless, MY version of the problem remains unsolved

Community
  • 1
  • 1
Bukov
  • 613
  • 8
  • 18
  • Show us your `.gitignore` file. – trojanfoe Jan 20 '13 at 15:24
  • 1
    "I completely deleted _my_ .gitignore file" - Then you deleted a file that's not relevant. Check your global `~/.gitignore` file and the `.gitignore` files in all directories between the root of your project and the `.idea` folder – AD7six Jan 20 '13 at 15:29
  • possible duplicate of [Git is ignoring files that aren't in gitignore](http://stackoverflow.com/questions/9436405/git-is-ignoring-files-that-arent-in-gitignore) - and yes I read the "similar-but-unsolved thread" part of the question. – AD7six Jan 20 '13 at 15:38

3 Answers3

6

Do you have ~/.gitignore file? Here is the information that may be helpful.

Git has a very flexible hierarchy of ignore files: First it reads .gitignore file in your home directory. Put here common data for all repos (*.bak, for example, you definitely do not need them in any repo). Then, you can have .gitignore file in any folder inside your repo. It impacts on any files in this folder and its subdirectories. Also, you can have excludes in .git/info/exclude. It differs from .gitignore because it is not indexed, and you can put personal settings here. Of course ~/.gitignore is not indexed too.

madhead
  • 25,830
  • 14
  • 131
  • 174
  • 2
    @madhead you are a hero! There was indeed a ~/.gitignore file. It had the following 3 things (without quotes): "*~", ".DS_Store", and ".idea". I don't know where the file came from, if it was created by the original git install or one of the billion git gui's I tried. However the first 2 of those are fine and I'm glad he added them. I manually deleted the .idea line, and all was solved. Thanks! – Bukov Jan 20 '13 at 16:04
0

I had the same problem. In my .git/exclude/info file, I exclude the names of executables that are created. But I often use the same name for the directories in which these executables reside, e.g. the "sphere" directory contains the executable "sphere". Since I had added all of the files before excluding the executable names in info/exclude, the fatal error never kicked in, even after excluding the directory/executable name to info/exclude.

Recently, however, I tried to add a file from a directory whose name was already excluded (because it matched the name of an executable I was excluding). The fatal error kicked in, and I was confused. I forced the add, and now any subsequent adds ignore the fatal error.

What this suggests is that it makes sense to exclude executable names in local .gitignore files, rather than in info/exclude.

Donna
  • 987
  • 1
  • 7
  • 26
0

If using the -f flag doesn't make any difference (i.e. the file still doesn't get staged), double check that the thing you're trying to add isn't already in the repository.

In my case I was trying to add something that had already been added and then deleted on a different branch, leading me to incorrectly think it had never been added in the first place. And Git was quite reasonably refusing to add the same thing twice.

Matthew Strawbridge
  • 18,016
  • 10
  • 65
  • 86