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.

I want to remove a folder from a Git repository but I get an error.

I tried several commands, and here you can see my errors:

selnaz:iOS Lnaz$ ls
iOS-Tidinfo mockup      readme.txt
selnaz:iOS Lnaz$ git rm -r -- iOS-Tidinfo/
fatal: pathspec 'tidinfo/iOS/iOS-Tidinfo/' did not match any files
selnaz:iOS Lnaz$ git rm -r iOS-Tidinfo/
fatal: pathspec 'tidinfo/iOS/iOS-Tidinfo/' did not match any files
selnaz:iOS Lnaz$ git rm -r iOS-Tidinfo/
fatal: pathspec 'tidinfo/iOS/iOS-Tidinfo/' did not match any files
selnaz:iOS Lnaz$ git rm -r tidinfo/iOS/iOS-Tidinfo/
fatal: pathspec 'tidinfo/iOS/tidinfo/iOS/iOS-Tidinfo/' did not match any files

Edit

selnaz:iOS Lnaz$ rm -r iOS-Tidinfo
override r--r--r--  
Lnaz/staff for iOS-Tidinfo/.git/objects/00/ae692a7725dfb4af05e3051a8c3ba78b7f0706? ls
rm: 
iOS-Tidinfo/.git/objects/00: Directory not empty
override r--r--r--  Lnaz/staff for 
 iOS-  Tidinfo/.git/objects/01/6bdb82585a4b0660f0da5ee8e0a3fef8474073?
share|improve this question
add comment

1 Answer

You cannot remove a folder in Git, as you cannot add one.

Git can only manage files. So, to remove a folder you will have to remove every file inside that folder:

git rm iOS-Tidinfo/* ; git commit -a

If the folder is empty or all the files inside are not tracked by Git you can simply remove the folder with:

rm -r iOS-Tidinfo
share|improve this answer
    
when I add you comment I got this selnaz:iOS Lnaz$ rm -r iOS-Tidinfo override r--r--r-- Lnaz/staff for iOS-Tidinfo/.git/objects/00/ae692a7725dfb4af05e3051a8c3ba78b7f0706? ls rm: iOS-Tidinfo/.git/objects/00: Directory not empty override r--r--r-- Lnaz/staff for iOS-Tidinfo/.git/objects/01/6bdb82585a4b0660f0da5ee8e0a3fef8474073? –  Elnaz Shahmehr Jun 26 '12 at 15:17
    
@ElnazShahmehr: Please state in your question what is the git directory root folder and what is the folder you want to remove. Considering the output you just provided you are trying to remove your repository root folder. –  criziot Jun 26 '12 at 15:19
    
I have all this folders timereportingtools/tidinfo/iOS/iOS-Tidinfo/ my git repository is timereportingtools/ and I want to remove iOS-Tidinfo/ folder –  Elnaz Shahmehr Jun 26 '12 at 19:58
    
@ElnazShahmehr: Your last edit shows that you have a .git folder inside the iOS-Tidinfo, what is not supposed since you should only have a .git folder inside your root repository folder. If you don't have uncommited changes I recomend you to clean your working directory with git clean -df, or clone the repository again. –  criziot Jun 26 '12 at 20:24
    
thannks for your reply , git clean -df didn't work I think I should clone it again! –  Elnaz Shahmehr Jun 26 '12 at 21:56
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.