Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

gitでディレクトリ構成を変更したい場合 (git mv)

前回の記事にて、その時点の知識でgitのディレクトリ構造の変更を試みたわけですが……
なんと、トラックバックさせて頂いたサイトの管理人kanonji様から、

もし、ファイルの位置を変えたいだけでしたら`git mv`というコマンドもありますよ。

という情報を頂きました。

公式リファレンスを参照すると*1

git mv [-v] [-f] [-n] [-k] <source> ... <destination directory>

OPTIONS
-f
--force
Force renaming or moving of a file even if the target exists

-k
Skip move or rename actions which would lead to an error condition. 
An error happens when a source is neither existing nor controlled by GIT, 
or when it would overwrite an existing file unless -f is given.

-n
--dry-run
Do nothing; only show what would happen

-v
--verbose
Report the names of files as they are moved.

以上、公式リファレンスより抜粋

前回の場合、

#git mv ./info/src/cygwin ./src

だけで行けてしまいます。
shellのmvと同じようにリネームもできるみたいです。


参照もと

*1:恥ずかしながら今まで見てませんでした(汗)