Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ignores directory that is not in .gitignore, exclude or config file

I have a directory in my project that is being ignored but it is not in any of the places that I would expect ignored folders to be (.gitignore, exclude or config).

it is an Android Studio project that I build with gradle, my VCS is Git. I'm using SourceTree & GitBash to manage the repo. I've reset all .ignore files in my project to be empty, \info\exclude is empty and config doesn't have 'excludesfile' property.

folder being ignored is - 'myProj/app/src/debug/res/raw/' have no idea how this folder got ignored in the first place. there is a different relative folder 'myProj/app/src/debug/res/values' that is tracked by git.

Is there any other place I didn't look that set ignore files? Is there any git command that can show where is this folder being set as ignored folder? maybe a binary I overlooked that I can just delete?

currently running 'git status --ignored' show only 'myProj/app/src/debug/res/raw/' as ignored.

like image 700
Alon Eirew Avatar asked Feb 09 '15 12:02

Alon Eirew


4 Answers

Use git check-ignore -v myProj/app/src/debug/res/raw/ to see where the ignore is. You may have to give it the name of a file in that directory instead of the directory itself.

like image 95
Chris Avatar answered Oct 16 '22 09:10

Chris


Thanks guys for responding so quick,

I've eventually resolved the issue by just adding the folder using:

  • git add -f myProj/app/src/debug/res/raw/

then commit and push, this was suppose to be a meanwhile solution until real solution is found but did the trick, after doing that the folder started to be tracked.

like image 40
Alon Eirew Avatar answered Oct 16 '22 09:10

Alon Eirew


Note that your rule may also exist in the .gitignore_global file (in your user folder). You may have accidentally added it by choosing "Global ignore list" in the "Add this ignore entry to" dropdown in SourceTree.

Don't do this!

You usually don't want to add a folder name to your global ignore list

like image 3
Mattijs Avatar answered Oct 16 '22 11:10

Mattijs


I know this question is 5 years old but it's the first one on Google results.

Another possibility besides the ones mentioned before is that the folder has been added as a submodule. E.g. in GitHub, the bottom folder is a submodule:

Example

This happened to me recently while copying a whole git project into another. That is, my repo looked like this:

repo
|
|__ .gitignore
|__ .git/ #git folder for repo
|__ some_files.ext
|
|__ ignored_folder
     |__ .git/ #git folder of the copied repo
     |__ .gitignore
     |__ some_other_files.ext

My specific solution was to:

  1. Cut the whole ignored_folder outside of the repo.
  2. Add&commit to delete the submodule in the repo
  3. Delete the .git folder inside the moved ignored_folder.
  4. Move the ignored_folder back in.
  5. Add&commit.

However, I'm sure there are much better git-like solutions.

like image 1
Guillermo J. Avatar answered Oct 16 '22 09:10

Guillermo J.