Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
- 2.44.0 02/23/24
- 2.43.1 → 2.43.3 no changes
- 2.43.0 11/20/23
- 2.39.1 → 2.42.1 no changes
- 2.39.0 12/12/22
描述
移动或重命名一个文件、目录或符号链接。
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 be either a file, symlink or directory, to <destination>. In the second form, the last argument has to be an existing directory; the given sources will be moved into this directory.
在移动成功完成后,索引就会被更新,但更改仍需要进行提交才能生效。
子模块
Moving a submodule using a gitfile (which means they were cloned with a Git version 1.7.8 or newer) will update the gitfile and core.worktree setting to make the submodule work in the new location. It also will attempt to update the submodule.<name>.path setting in the gitmodules[5] file and stage that file (unless -n is used).
漏洞
每当父工程更新导致子模块移动时(例如,在移动之前和之后的提交之间切换时),旧位置将保留一个陈旧的子模块检出,并在新位置出现一个空目录。要在新位置重新填充子模块,用户必须运行 "git submodule update"。只有在旧目录使用 gitfile 时,删除旧目录才是安全的,否则子模块的历史记录也将被删除。当实现递归子模块更新时,这两个步骤将变得不再需要。
GIT
属于 git[1] 文档