blob: dc1bf61534106ac8c9e916ba47bb7fb0f1bf97f0 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-mv(1)
2=========
3
4NAME
5----
Junio C Hamano7c73c662007-01-19 00:37:506git-mv - Move or rename a file, a directory, or a symlink
Junio C Hamano1a4e8412005-12-27 08:17:237
8
9SYNOPSIS
10--------
Junio C Hamano15567bc2011-07-23 00:51:5911[verse]
Junio C Hamanocf9c7732022-10-28 18:56:0612'git mv' [<options>] <source>... <destination>
Junio C Hamano1a4e8412005-12-27 08:17:2313
14DESCRIPTION
15-----------
Junio C Hamano33be8212023-10-23 21:45:5416Move or rename a file, directory, or symlink.
Junio C Hamano1a4e8412005-12-27 08:17:2317
Junio C Hamano0df92712011-12-21 22:30:4418 git mv [-v] [-f] [-n] [-k] <source> <destination>
Junio C Hamano6546a502024-02-08 23:48:3619 git mv [-v] [-f] [-n] [-k] <source> ... <destination-directory>
Junio C Hamano1a4e8412005-12-27 08:17:2320
21In the first form, it renames <source>, which must exist and be either
22a file, symlink or directory, to <destination>.
23In the second form, the last argument has to be an existing
24directory; the given sources will be moved into this directory.
25
26The index is updated after successful completion, but the change must still be
27committed.
28
29OPTIONS
30-------
31-f::
Junio C Hamano68cfa3a2009-08-30 00:22:5532--force::
Junio C Hamanocf9c7732022-10-28 18:56:0633Force renaming or moving of a file even if the <destination> exists.
Junio C Hamano1a4e8412005-12-27 08:17:2334-k::
Junio C Hamano92d80372016-07-13 22:00:0535Skip move or rename actions which would lead to an error
Junio C Hamano1a4e8412005-12-27 08:17:2336condition. An error happens when a source is neither existing nor
Junio C Hamano076ffcc2013-02-06 05:13:2137controlled by Git, or when it would overwrite an existing
Junio C Hamano92d80372016-07-13 22:00:0538file unless `-f` is given.
Junio C Hamanoeb415992008-06-08 22:49:4739-n::
40--dry-run::
Junio C Hamano1a4e8412005-12-27 08:17:2341Do nothing; only show what would happen
42
Junio C Hamano0df92712011-12-21 22:30:4443-v::
44--verbose::
45Report the names of files as they are moved.
46
Junio C Hamano8eac2682013-09-09 22:35:2047SUBMODULES
48----------
49Moving a submodule using a gitfile (which means they were cloned
50with a Git version 1.7.8 or newer) will update the gitfile and
51core.worktree setting to make the submodule work in the new location.
52It also will attempt to update the submodule.<name>.path setting in
53the linkgit:gitmodules[5] file and stage that file (unless -n is used).
54
Junio C Hamanobc8d4782014-01-13 23:35:5055BUGS
56----
57Each time a superproject update moves a populated submodule (e.g. when
58switching between commits before and after the move) a stale submodule
59checkout will remain in the old location and an empty directory will
60appear in the new location. To populate the submodule again in the new
61location the user will have to run "git submodule update"
62afterwards. Removing the old directory is only safe when it uses a
63gitfile, as otherwise the history of the submodule will be deleted
64too. Both steps will be obsolete when recursive submodule update has
65been implemented.
66
Junio C Hamano1a4e8412005-12-27 08:17:2367GIT
68---
Junio C Hamanof7c042d2008-06-06 22:50:5369Part of the linkgit:git[1] suite