Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Sam Lillicrap
Sam Lillicrap
12,127 Points

Git code question

I'm on git repo basics, doing the first code challenge and I'm somehow stuck, can't see what I'm doing wrong:

"Oops! I just decided we're in the wrong folder. Let's remove the git repository we just created."

Answers I've tried:

       ``` rm ~/project_folder ``` 
       ``` rm ~/project_folder/.git ``` 
       ``` rmdir ~/project_folder``` 
       ``` rmdir ~/project_folder/.git ``` 

Apparently none of them would remove the git repo... I'd like to think they all would but there's only one possible answer for this quiz

Any ideas? :-)

6 Answers

You're on the right track. The challenge assumes that you've created a git repository in your current directory, so you shouldn't specify a directory path in your rm command. Your second line of code is almost correct..

You also need to use the -r flag to remove a directory (such as the .git directory). Take a look at this link for examples of removing a directory http://www.computerhope.com/issues/ch000798.htm

Sam Lillicrap
Sam Lillicrap
12,127 Points

Okay great cheers I managed to solve it. I'm still a little confused as to why I have to use the -r flag to move directories but not files though?

Read the man page for rm, it talks all about it. If you remove a file, you're giving a specific location. A folder holds files, so you have to throw the recursive flag so it recursively deletes all child files.

It's to make it less likely that you'll accidentally delete an entire directory.

Michael Reining
Michael Reining
10,101 Points

So what is the answer? I have tried about 20 different variations. This is a super frustrating quiz. :(

Here was my last attempt:

rm -r ~/project_folder/.git

I finally solved it but it is absolutely not clear that the terminal is assuming that the users is in the current directory. In fact, you list the project_folder directory in Q1 above which completely throws users off. Either accept both answers or make it very obvious via the terminal prompt of where the user is.

The final answer for those also frustrated and stuck just enter:

> rm -r .git
James Barnett
James Barnett
39,199 Points

Seems like that code correctness check is overly specific, the 2 versions you posted should both work equally well, I'd say that's a bug. Send an email to help@teamtreehouse.com to let them know about the bug you found.

Michael Reining
Michael Reining
10,101 Points

Done. Overall I am loving Treehouse so happy to help.

rmdir only works on empty directories. The command you're looking for is rm -rf (recursive and permissions flags). info rm in terminal and read up on the flags, they are good to know.

The directory you need to remove to destroy the repo is the .git in your project directory.

James Barnett
James Barnett
39,199 Points

Check out http://ss64.com/bash/rm.html

You can use http://ss64.com/bash/ for all of your man page needs via the web.

nice resource, I will mark this

I always kinda like man.he.net but this page would work on small screens.

James Barnett
James Barnett
39,199 Points

I really like that ss64 typically only includes the flags and adds in some examples. man.he.net is great if you need info that isn't on ss64.com

rm-r .git