• 追加された行はこの色です。
  • 削除された行はこの色です。
#author("2020-09-01T07:23:43+09:00","default:ryuichi","ryuichi")
* git addの取消し [#wde3ef9b]
#author("2020-10-24T11:16:38+09:00","default:ryuichi","ryuichi")
* git addの取消し(ファイルを管理対象外にする)[#wde3ef9b]

** ここでのgit addの取消しとは? [#za1f5fef]
** 前提 [#a0bbfe5f]

- '''git add'''してステージしたファイルをINDEXから削除する
- その際、ファイル自体はワーキングディレクトリから削除しない
 git add test.txt
 git commit -m 'Added test.txt'

** 手順 [#y46e46fb]
- test.txtは管理対象になっている

 > git add 1.txt           # (1)
 > git status
 ## master
 A  1.txt
 
 > git rm --cached 1.txt   # (2)
 rm '1.txt'
 
 > git status              # (3)
 ## master
 ?? 1.txt
** ファイルを管理対象外にする(実際のファイルを削除する) [#n98e074c]

- (1) 1.txtをgit addする
- (2) git rm --cachedでそのgit addを取り消す
- (3) INDEXから削除されたが、ファイル自体は存在している
 git rm test.txt

- test.txtはディレクトリから削除される

** ファイルを管理対象外にする(実際のファイルはそのままにしておく) [#i72939d8]

 git rm --cached test.txt


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS