修正・削除したファイルを元に戻す

修正したファイルを戻す

 vi 1.txt                   # (1)
 git checkout 1.txt

任意のリビジョンに戻す

 vi 1.txt
 git checkout abc123 1.txt  # (2)
 git checkout HEAD 1.txt    # (3)
 
  • (2) リビジョンabc123に戻す
  • (3) HEADに戻す。(1)と同じ意味

削除したファイルを戻す

 rm 1.txt            # (1)
 git restore 1.txt
 git rm 1.txt        # (2)
 git restore 1.txt
  • (1)シェルで削除した場合も(2)git rmで削除した場合も、
  • コマンドgit restoreで戻せる

git addでステージに上げたファイルを戻す

 vi 1.txt        # (1)
 git add 1.txt
 git reset 1.txt
  • 'git addは取り消されるが、ファイルの内容は(1)で修正されたまま

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2022-01-20 (木) 13:22:20