简体   繁体   中英

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.

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.

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.

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.

不要这样做!

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

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. Eg in GitHub, the bottom folder is a submodule:

例子

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM