How to move directory to another directory using git

4.2k views Asked by At

I have one directory 'Checkout' that needs to move to the directory 'screens'. I do not want to overwrite the screens folder, I just want to add Checkout to it. This is all on local machine.

So far I have created and navigated to a new branch. The idea is to move the entire directory in this branch, add/commit the changes then push this branch with the changed directory location to remote.

I have tried this command...

git mv app/Checkout ... app/screens

but I get

fatal: bad source, source=..., destination=app/screens/...

What am I missing?

2

There are 2 answers

0
Calum Halpin On BEST ANSWER

The command you want is git mv app/Checkout app/screens. The triple dots in the docs indicate that you can provide multiple source arguments, not literal dots.

0
SwissCodeMen On

The error fatal: bad source ... usually indicates that after last commit there were some renames in the source directory and hence git mv can‘t find the expected file. Just git commit before execute git mv.

And why ? You can simple execute the git mv-command as follow:

git mv app/Checkout app/screens

Look at Git-docu