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 Git Basics Getting Started With Git Working With Git Repositories

Wei-Ting Chen
Wei-Ting Chen
7,632 Points

sudo:command not found

well in this class (https://teamtreehouse.com/library/git-basics/getting-started-with-git/working-with-git-repositories), I typed "sudo git init my_first_repository",but the result showed "sudo:command not found"

Where did I do wrong? How can I fix this? I ran this code on Git Bash in the Win7 64bit environment thanks!

1 Answer

Have you tried running this command without using sudo? As you know sudo is only need for hard changes to an environment, where administrator access is needed. The command should create the repository just fine with:

git init my_first_repository

Sudo should not be needed if all you are doing is essentially making a new folder, just make sure you are making this repository in a place you want, I like to move my code all neatly in a folder on my desktop. I hope this helps! Please tell me if it doesn't work and I will continue to work with you!

Wei-Ting Chen
Wei-Ting Chen
7,632 Points

Still doesn't work,it shows "fatal:cannot mkdir my_first_repository:Permission denied" Thanks you so much

Hmm, it sounds like for some reason your file permissions are set so that you and the super user (sudo) cannot actually make a file in the environment you are in. In that case I would:

A) Make sure you are in a directory you can actually make your repository in. If you are trying to do all of this from the default location or your system root then you might be able to move somewhere you can actually have the file permissions with or without sudo. Try making a folder on your desktop named something like "Git_Code" then using the cd command to change directories into in, then try making the repository there

B) Change the file permissions of where you are to allow you to make the repository in the directory you are in. I found a helpful little question on stackoverflow that explains how this exact error works just like it is happening to you here:

http://stackoverflow.com/questions/12996397/command-not-found-when-using-sudo

Also be sure to check out the treehouse video on file permissions from the Console Foundations Course - Users and Permissions for more info and explanation here:

http://teamtreehouse.com/library/console-foundations

I would definitely try A first because I think this might be your problem, but it might very well be if A does not work you might need to mess with your file permissions and PATH. Again, hope this helps you and sorry if my explanation is not working for you!

Wei-Ting Chen
Wei-Ting Chen
7,632 Points

Alex thank you so much for so detailed answers! I find that the problem is the case A you just mentioned,I accidentally change to other directory without noticing. Once again thank you so much

Glad I could be of help :D keep up the good work Wei and don't worry about asking questions, people on the Treehouse forums are really helpful!