Anga
Anga

Reputation: 2662

Moving files from a directory to my current directory using git command

I am in need of the exact command to move a file from a directory to another. Lets say move a file (file1.txt) in my Downloads directory to my current directory (version-control/newfolder) in git bash using git command?

I tried this command initially

mv ~/Downloads lesson_3_reflecton_prompts.txt

and it moved my Downloads directory to my version-control/newfolder direcotry and also changed the path of the Downloads directory.

I tried this other commad

mv Downloads/file1.txt file1.txt

and I got this error

mv: cannot stat 'Downloads/file1.txt': No such file or directory

I know there is a code to do this, I need it, and I have been searching for it.

Help

Upvotes: 0

Views: 7139

Answers (1)

Marina Liu
Marina Liu

Reputation: 38136

Use below commands to move file1.txt from Downloads directory to your git repo:

mv ~/Downloads/file1.txt file1.txt

And if you want to commit the file1.txt into your git repo, you can use the commands:

git add file1.txt
git commit -m 'add a file'

Upvotes: 3

Related Questions