Git work structure, git Structure

Source: Internet
Author: User

Git work structure, git Structure
Create a version Library

First select a directory (make sure that the directory name does not contain Chinese characters), and thengit bash, And then under this directory$ git initChange this directory to a git-managed repository (repository)

In this way, git has established the repository (gitTest), and there will be. git Directory, which is used by Git to track and manage version libraries. Never modify the files in this directory manually. Otherwise, the Git repository will be damaged.
If you do not see the. git directory, it is because the directory is hidden by default. You can see it using the ls-ah command.

Working Directory)

Is the directory that can be seen in the computer, for example, the gitTest folder is the Workspace

Version Library (Repository)

There is a hidden directory in the workspace. git, which is not the workspace, but the Git version library.

The Git version library stores a lot of things, the most important of which is the stage (or index) temporary storage zone, and the first branch master that Git automatically creates for us, and a pointer to the master is HEAD.


Next, let's talk about Branch and HEAD.

The entire process is:
Step 1: Add or modify files in the workspace firstgit addAdd to temporary storage Zone
Step 2:git commitSubmit all content in the temporary storage area to the master of the current branch.
Note: When we create a Git version library, Git automatically creates a unique master branch for us. Therefore, git commit is to submit changes to the master branch.

For example, add an object:
1. Compile a readme.txt file under the gittestfolder with the following content:

1  add a file called README

2,$ git add readme.txtAdd files to the temporary storage area in the version Library
3,$ git statusView the status at this time, as shown in:

"Changes to be committed:" indicates the content to be submitted in the temporary storage area.
4,$ git commit -m "add a file named README"Submit the content in the temporary storage area to the current branch. Note:-m is followed by the description of this submission. You can enter any content. Of course, it is best to make sense, in this way, you can easily find the change records from the history records.

Git checkout has one line of content ).

5. If you have made any changes to the workspace after submitting the application, the workspace is clean.git statusView:

Now the version library has become like this, so there will be no content in the temporary storage zone:

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.