Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

below is directory structure:

Top_dir
--test_file

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 stackoverflow.com Apr 12 '13 at 7:48

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

2  
Yes, git only cares about files, not directories. stackoverflow.com/questions/115983/… –  Ismail Badawi Apr 12 '13 at 3:58
add comment

2 Answers

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
add comment

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

http://gitref.org/basic/#rm-mv

https://www.kernel.org/pub/software/scm/git/docs/git-rm.html

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
add comment

Your Answer

 
discard

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.