git mv
命令用於移動或重命名檔,目錄或符號鏈接。
簡介
git mv <options>… <args>…
描述
移動或重命名檔,目錄或符號鏈接。
git mv [-v] [-f] [-n] [-k] <source> <destination>
git mv [-v] [-f] [-n] [-k] <source> ... <destination directory>
在第一種形式中,它將重命名<source>
為<destination>
,<source>
必須存在,並且是檔,符號鏈接或目錄。 在第二種形式中,最後一個參數必須是現有的目錄; 給定的源(<source>
)將被移動到這個目錄中。
索引在成功完成後更新,但仍必須提交更改。
示例
以下是一些示例 -
把一個檔:text.txt 移動到 mydir,可以執行以下操作 -
$ git mv text.txt mydir
運行上面的 git mv
其實就相當於運行了3
條命令:
$ mv test.txt mydir/
$ git rm test.txt
$ git add mydir
上一篇:
git rm命令
下一篇:
git branch命令