2015-12-17 21:22:16 +00:00
|
|
|
# git mv
|
|
|
|
|
2021-01-07 14:06:38 +00:00
|
|
|
> Move or rename files and update the Git index.
|
2019-06-03 01:06:36 +01:00
|
|
|
> More information: <https://git-scm.com/docs/git-mv>.
|
2015-12-17 21:22:16 +00:00
|
|
|
|
2023-05-25 18:32:56 +01:00
|
|
|
- Move a file inside the repo and add the movement to the next commit:
|
2015-12-17 21:22:16 +00:00
|
|
|
|
|
|
|
`git mv {{path/to/file}} {{new/path/to/file}}`
|
|
|
|
|
2023-05-25 18:32:56 +01:00
|
|
|
- Rename a file or directory and add the renaming to the next commit:
|
2015-12-17 21:22:16 +00:00
|
|
|
|
2023-05-25 18:32:56 +01:00
|
|
|
`git mv {{path/to/file_or_directory}} {{path/to/destination}}`
|
2015-12-17 21:22:16 +00:00
|
|
|
|
2023-05-25 18:32:56 +01:00
|
|
|
- Overwrite the file or directory in the target path if it exists:
|
2015-12-17 21:22:16 +00:00
|
|
|
|
2023-05-25 18:32:56 +01:00
|
|
|
`git mv --force {{path/to/file_or_directory}} {{path/to/destination}}`
|