私は次のコマンドを実行し、git diff HEAH
などgit diff
「間違った」出力
[email protected] MINGW64 ~/Desktop/path/to/my/workspace/demo
$ git init
Initialized empty Git repository in C:/Users/Athrun/Desktop/path/to/my/workspace /demo/.git/
[email protected] MINGW64 ~/Desktop/path/to/my/workspace/demo (master)
$ echo "Hello World" > welcome.txt
[email protected] MINGW64 ~/Desktop/path/to/my/workspace/demo (master)
$ git add welcome.txt
[email protected] MINGW64 ~/Desktop/path/to/my/workspace/demo (master)
$ git commit -m "\"Hello World\" committed"
[master (root-commit) eb00b00] "Hello World" committed
1 file changed, 1 insertion(+)
create mode 100644 welcome.txt
[email protected] MINGW64 ~/Desktop/path/to/my/workspace/demo (master)
$ git rm --cached welcome.txt
rm 'welcome.txt'
[email protected] MINGW64 ~/Desktop/path/to/my/workspace/demo (master)
$ git diff HEAD
diff --git a/welcome.txt b/welcome.txt
deleted file mode 100644
index 557db03..0000000
--- a/welcome.txt
+++ /dev/null
@@ -1 +0,0 @@
-Hello World
[email protected] MINGW64 ~/Desktop/path/to/my/workspace/demo (master)
$ git diff
によって出力について混乱しましたが、基本的に私は、文字列を使用してファイルを作成し、レポを初期化"Hello World"とファイルをコミットしました。次に、私はgit rm --cached welcome.txt
コマンドを実行して、 "ファイル"(ここでは "ファイル"と呼んでよいかどうかはわかりません)を削除してステージング領域に入れました。次に、HEADとステージング領域の変更を比較する2つのコマンドgit diff HEAD
とgit diff
を実行しました。
私がここで理解しているのは、作業ディレクトリとHEADに同じバージョンのファイルがあり、 'git diff HEAD'は何も表示されず、 'git diff'には「Hello World」が削除されている必要があります。
ただし、出力は正反対です。
@PetSerAIあなたの答えをありがとう、私は気づいていないrm - キャッシュは、ファイルをuntracks。それは大いに役立ちます。 – user1888955