Consider the following sequence of commands, which does the following:
1.Creates two branches (master
and test_branch
), where master
has two commits, and test_branch
has one commit.
2. The final state is that test_branch
is checked out, but the working directory should match the tree at the tip of master exactly.
git init .
git commit --allow-empty -m 'Initial commit'
echo FOO > FOO.txt
git add FOO.txt
git commit -m 'Added foo'
git checkout -b test_branch HEAD^
git status
git checkout master -- .
git reset
git diff master
The output of this sequence of commands is the following:
diff --git a/FOO.txt b/FOO.txt
deleted file mode 100644
index b7d6715..0000000
--- a/FOO.txt
+++ /dev/null
@@ -1 +0,0 @@
-FOO
However, my working directory has FOO.txt
with exactly the contents that git
claims are missing:
cat FOO.txt
FOO
Is there some alternate invocation of git diff
or lower level command that will force it to take the literal working tree and compare it with a commit, instead of pretending the untracked files in the working tree do not exist for the purposes of comparison?