The most basic code:
git mv File_old file_new
Manual:
NAME
Git-mv-move or rename a file, a directory, or a symlink
Synopsis
git mv <options>, ...? <args>, ...?
DESCRIPTION
Move or rename a file, directory or symlink.
git mv [-v] [-f] [-n] [-K] <source> <destination>git MV [-v] [-f] [-n] [-K] <source> ... <destination Directory>
In the first form, it renames <source>, which must exist and is either a file, symlink or directory, to <destinat Ion>. The second form, the last argument have to is an existing directory; The given sources'll be moved to this directory.
The index is updated after successful completion and the change must still be committed.
OPTIONS
-
-F
-
--force
-
Force renaming or moving of a file even if the target exists
-
-K
-
Skip move or rename actions which would leads to an error condition. An error happens when a source was neither existing nor controlled by Git, or if it would overwrite an existing file Unle SS- F is given.
-
-N
-
--dry-run
-
Do nothing; Only show what would happen
-
-V
-
--verbose
-
Report the names of files as they is moved.
Submodules
Moving a submodule using a gitfile (which means they were cloned with a Git version 1.7.8 or newer) would update the Gitfil E and Core.worktree setting to make the submodule work on the new location. It also would attempt to update the Submodule.<name>.path setting in the gitmodules[5] file and stage that file (Unle Ss-n is used).
BUGS
Each time a superproject update moves a populated submodule (e.g. when switching between commits before and after the move A stale submodule checkout would remain in the old location and an empty directory would appear in the new location. To populate the Submodule again in the new location the user would have a to run "git submodule update" afterwards. Removing the old directory was only safe when it uses a gitfile, as otherwise the history of the submodule would be deleted Too. Both steps would be obsolete when recursive submodule update had been implemented.
Git mv command to move or rename