Git mv command to move or rename

Source: Internet
Author: User
Tags symlink

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.