Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does git keep deleting my folder?

Tags:

git

I have a folder in my repository called 'activity'. It keeps getting strangely deleted from the repository, and isn't seen as an untracked file.

In github, it is rendered as a folder with a green arrow, and the text '→ f32111b' next to it. This has happened several times now, and only with this one folder.

I've already checked .gitignore. Is there another reason why a folder called 'activity' would be trouble in git?

like image 465
jamtoday Avatar asked Jul 09 '09 05:07

jamtoday


People also ask

Does git remove empty directory?

Git does not delete empty folder but it has no concept of folders therefore it does not track folders (git only tracks paths to your files, not folders, it treats file paths like how you'd treat URLs on a website).

What to do when git deleted files?

If you have deleted the file and already committed the changes, you need to use the ` git checkout` command to restore the file. First, you need to find out the checksum of the commit that deleted the file, and then check out the file from the previous commit.

Is .git folder ignored by default?

git folder is ignored by default. All others are deamed potentially important for the source-base unless configured otherwise within the repository or at a global level.

Why does git ignore empty folders?

Git doesn't ignore empty directories. It ignores all directories. In Git, directories exist only implicitly, through their contents. Empty directories have no contents, therefore they don't exist.


1 Answers

That's not a directory, that's a submodule. Or at least GitHub seems to think so.

What does your .gitmodules file look like? Did you maybe forget to run git submodule init and git submodule update?

Submodules can be a little bit tricky, especially when you convert from a directory to a submodule or back.

like image 168
Jörg W Mittag Avatar answered Sep 21 '22 17:09

Jörg W Mittag