1

I work on a git repo with many many branches in it. Now i wanted to add a new feature from another location. So i did cp -r /source /target
The new files are in my repo, but git ignores them.
If i do git status after i copied that files, git says 'working directory clean'...
Why this happens? It is not ignored in .gitignore. I tried this also with other files, these files appear immediately in git status. What i did wrong and how i can fix this?

I read the other answers, but cant't find answers which helped.

Mathiou
  • 399
  • 2
  • 12
Maik Hagenbruch
  • 83
  • 1
  • 13
  • Can you add the exact names of your files/directory and the content of your .gitignore file ? – Mathiou Oct 12 '15 at 09:50
  • file names are in ~/sites/project/typo3conf/ext/tagger and .gitignore contents are here: http://pastebin.com/iJULC0p2 I dont think thats related with this problem because i added other files into the .../ext/ directory - that works. But have a look. – Maik Hagenbruch Oct 12 '15 at 09:54
  • That's juste the `tagger`repo that is ignored ? You're right, can't see the reason in your `.gitignore`file... Maybe have a look at this : http://365git.tumblr.com/post/519016351/three-ways-of-excluding-files – Mathiou Oct 12 '15 at 10:06
  • yes, only the tagger folder is ignored. I tried to add another directory. This appears directly as change in git. – Maik Hagenbruch Oct 12 '15 at 10:08
  • Have you tried to put the `tagger` repo in a different location ? Like at the root of your project, just to see what happens ? – Mathiou Oct 12 '15 at 10:18
  • Oh, i think i found whats going wrong. I i copied the tagger dir, there was also an .git dir. I deleted this after the copy. I think git made a submodule from this. So, now i have to look how to clean up this. – Maik Hagenbruch Oct 12 '15 at 10:22
  • Are you saying that just removing the `.git` repo made `tagger` appear as a change ? – Mathiou Oct 12 '15 at 10:26
  • no, i didnt had a look what happens directly after copying the tagger dir into my repo. I saw a few minutes later that there is also a .git dir in tagger. So i removed that. And later, if i wanted to commit the changes, i saw there isnt the new tagger dir to add. – Maik Hagenbruch Oct 12 '15 at 10:28

1 Answers1

1

Possible reasons in order of likelihood:

  • /target isn't inside your working directory
  • One of the new folders is in .gitignore (which makes Git ignore all files in it).
  • You're looking in the wrong ignore file. Check your global ignore files: $HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore
  • You can have one .gitignore per folder. Check all the folders.
  • The files already existed with the exact same content

To debug the issue, try git check-ignore. See https://git-scm.com/docs/git-check-ignore

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820