Comparing the working tree with a commit should be independent of the index
- From
- Maaartin <grajcar@seznam.cz>
- Date
- Aug 18, 2012, 18:36 UTC
- Message-ID
- <502FE0C6.6050106@seznam.cz>
I've already posted it to SO [1], but got no satisfactory answer. The command
git diff mycommit
compares the working tree against mycommit, so it should not depend on the index. But it does as this example shows:
git init echo A > A.txt; git add .; git commit -m A; git branch A echo B > B.txt; git add .; git commit -m B; git branch B git reset --hard A echo BB > B.txt git diff B
File B.txt exists both in the working tree and in the commit B, so a proper diff should be shown.
Instead I get "deleted file". Adding the file to the index changes it. This is IMHO a bug.
[1]: http://stackoverflow.com/questions/8452820/how-to-compare-the-working-tree-with-a-commit