The output of Git diff is not the same under the action of different parameters. After understanding the workspace in Git, the latest version of staging area and the repository (current branch) is three different tree directories, which is a good understanding of Git diff's magical behavior.
Directory tree browsing for workspaces, staging area, and repositories
Is there any way to visually view the directory tree in staging area and head like a workspace view? For the tree that the head points to, you can use the git underlying command ls-tree to view it.
$ git ls-tree-l HEAD100644 blob bb2f2a2c99a6608b400a63a2acf44a441194651a welcome.txt
which
-
Use the-l parameter to display the size of the file. The size of the welcome.txt above is 58 bytes.
-
The output Welcome.txt file entry is left-to-right, the first field is the file's property (rw-r--r--), the second field description is a Blob object (file) in the Git object library, and the third field is the file's corresponding id--in the object library. An ID for the 40-bit SHA1 hash format (which is discussed later), the fourth field is the file size, and the fifth field is the filename.
Before browsing the directory tree in staging area, first clear the current changes in the workspace. Use the git clean-fd command to clear files and directories (non-tracked files and directories) in the current workspace that are not in the repository, and then execute git checkout. command to refresh the workspace with staging area content.
Git staging area git diff magic