時にはgitはgit rm --cachedファイルをステージング解除することを提案しますgit reset HEAD file。どちらを使用すればよいですか?
編集:
D:\code\gt2>git init
Initialized empty Git repository in D:/code/gt2/.git/
D:\code\gt2>touch a
D:\code\gt2>git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# a
nothing added to commit but untracked files present (use "git add" to track)
D:\code\gt2>git add a
D:\code\gt2>git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: a
#
D:\code\gt2>git commit -m a
[master (root-commit) c271e05] a
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
D:\code\gt2>touch b
D:\code\gt2>git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# b
nothing added to commit but untracked files present (use "git add" to track)
D:\code\gt2>git add b
D:\code\gt2>git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: b
#
rm、元に戻すことは論理的ではありませんaddか?どのrmように振る舞うべきだと思いますか?
git init必要がないということですHEAD。
rmUNIXコンテキストでの削除を意味します。インデックスへの追加と逆ではありません。ファイルを削除する関数は、ステージング状態を変更する関数でオーバーロードしないでください。それらを組み合わせるのに便利な実装の詳細がある場合、それは単にgitでの抽象化の思慮深い層の欠如を示しており、使いやすさが明確になります。
git rm両方のことができ、ステージの削除ともunstage ほか)