Gitに入門する -その4-
ステップ2の「Gitを初めからていねいに」をやる。
①ファイルを変更する
git mv 変更前ファイル名 変更後ファイル名
$ git mv hoge.txt hogehoge.txt $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: hoge.txt -> hogehoge.txt
②ファイルの移動
trashという新しいディレクトリを作成してそこにhogehoge.txtを移した。
$ git status On branch master Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) deleted: hogehoge.txt Untracked files: (use "git add <file>..." to include in what will be committed) trash/ no changes added to commit (use "git add" and/or "git commit -a")
git rmで消す
$ git rm hogehoge.txt rm 'hogehoge.txt'
$ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: hogehoge.txt Untracked files: (use "git add <file>..." to include in what will be committed) trash/
git addでディレクトリをステージングする
$ git add trash/
$ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: hogehoge.txt -> trash/hogehoge.txt
git mvを使ったバージョン
$ mkdir trash $ git mv hogehoge.txt trash/hogehoge.txt
終了。