Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

below is directory structure:


Now when I do git rm test_file, since Top_dir does not have any other files git is deleting Top_dir aswell. Is it normal behaviour of git?

share|improve this question

migrated from Apr 12 '13 at 7:48

This question came from our site for professional and enthusiast programmers.

Yes, git only cares about files, not directories.… – Ismail Badawi Apr 12 '13 at 3:58
up vote 0 down vote accepted

Yes. Git doesn't use a filesystem exactly. It uses "blobs". There's an article called git from the bottom up which is reasonably short and highly recommended. Here's a relevant snippet:

The difference between a Git blob and a filesystem’s file is that a blob stores no metadata about its content. All such information is kept in the tree that holds the blob. Onetree may know those contents as a file named “foo” that was created in August 2004, while another tree may know the same contents as a file named “bar” that was created five years later. In a normal filesystem, two files with the same contents but with such different metadata would always be represented as two independent files. Why this difference? Mainly, it’s because a filesystem is designed to support files that change, whereas Git is not. The fact that data is immutable in the Git repository is what makes all of this work and so a different design was needed. And as it turns out, this design allows for much more compact storage, since all objects having identical content can be shared, no matter where they are.

share|improve this answer

Hmm not really sure if git does that. It deletes files from your current working tree /index and staging area.

If you are a beginner with git , i suggest using gitk ( which provides a nice user interface to git repository ) making this easier. You can install that from terminal as sudo.

Hope that helps !

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.