4

Ok so I forked a project, ran git pull upstream master and git status said working directory clean. I then ran some tests from the project

now git status shows

# Untracked files: # (use "git add <file>..." to include in what will be committed) # # activemodel/log/ 

now $ git clean -d -f -n shows

# Would remove actionpack/test/temp/ # Would remove activemodel/log/ 

These are just directories for log files but I'm curious why actionpack/test/temp/ shows up in the git clean dry run but didn't show up in git status

This could cause problems if all untracked files don't show up in git status and then git clean would delete files you didn't realize it would delete.

Anybody know why this happens?

1 Answer 1

4

Are they empty directories?

Git does not track empty directories (actually Git does not track directories at all, as you can read in the Git FAQ), so they will not appear in git status, but they would indeed be cleaned by git clean -f -d.

That's why a dry run of such git-clean command is showing directories that do not appear otherwise with a regular git status.

As a side note, this is also why some people add a placeholder file, sometimes called .gitinclude by convention, inside empty directories in order to make Git track them.

Sign up to request clarification or add additional context in comments.

1 Comment

Ah that makes sense. activemodel/log/ has an empty test and development file, while actionpack/test/temp has no files. It is an empty directory so it doesn't show in git status. Now I understand. Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.