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

Farnoosh Johnson
Farnoosh Johnson
7,887 Points

git move command

I am in terminal using git. I made a directory on my desktop. I had another file "hello.html" on my desktop. I waned to move my "hello.html" file to my new folder directory I used this command: mv hello.html my_first_web_page

Now I lost my "hello.html" file.

Is anyone can help me to find it??

4 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Actually it's the same command

mv, depending on the context it was used, it can rename the file or move it to a new location.

Here's the typical syntax for mv.

mv <first argument> <second argument>

If you supply a directory path for the second argument, then mv will move the file to that folder. Say for example, you have a hello.html in the current directory, and you wish to move it to the Desktop. Here's the command for the job.

mv hello.html ~/Desktop
William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Hi, Farnoosh

mv hello.html my_first_web_page

Your hello.html file is NOT lost, the way you use the mv commend, it renamed the hello.html file to my_first_web_page within the same directory.

Hope it helps.

Farnoosh Johnson
Farnoosh Johnson
7,887 Points

thank you William, your answer was very helpful Quick question, what is the command for moving my file to a folder that I made on my desktop?