Git staging area git diff magic

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.