Git local repository

Source: Internet
Author: User

Original: http://www.cnblogs.com/wilber2013/p/4189920.html

Git Basic concepts

In git, we will need to have version control of the file directory called a warehouse (repository), each warehouse can be simply understood as a directory, all the files in this directory through Git to achieve version management, Git can track and record all updates that occur in that directory.

Now that we know what repository is (abbreviated repo), if we build a warehouse now (repo), there is a ". Git" folder in this directory where the repository is built. This folder is very important, all the version information, update records, and GIT for warehouse management information are all stored in this folder. Therefore, do not modify/delete the files in order to avoid the loss of data.

For further explanation, please refer to the following diagram, which will probably show the basic knowledge we need to know.

According to the picture above, a brief description of each section is given below:

    • Directory: A catalog that is managed with Git, which is a repository that contains our workspaces and the management space of Git.
    • WorkSpace: Directories and files that require version control through Git, which make up the workspace.
    • . Git: A directory that holds git management information and is created automatically when the repository is initialized.
    • Index/stage: Staging area, or call to submit the update area, we can put all the updates in staging area before committing to repo.
    • Local Repo: A native repository, a local repository, and head is just the current Development Branch (branch).
    • Stash: is a working state save stack for saving/recovering temporary state in workspace.

With the understanding of the above concepts, the following starts the GIT operation on the local repo.

Create a warehouse

The git Bash command-line window allows you to enter the directory where you want to build the repository, and you can easily build a repository with Git init.

At this point, our warehouse will automatically generate a ". Git" folder, which is the directory of the Git management information we mentioned earlier.

Add to

Now we create a new "test.txt" text file in the repository, which reads as follows.

123123

with "Git status" You can view the status of the workspace and see that the output shows that "test.txt" is not being tracked by git and that we can use "git add <file> ..." To add the file to the pending area (staging area).

Note that if you add to staging area, the update is only in workspace.

Use "git add test.txt" or "git Add.", then continue to view the status of workspace. At this point the discovery file has been put into staging area.

The update is now saved from workspace to the stage.

Finally, we can submit the update via "Git Commit-m". -M followed by a description of the commit (message).

The update is now saved from the stage to the local repo.

With the above operation, the file "Test.txt" was successfully added to the repository.

Update

Suppose you now need to update the "test.txt", after modifying the file, review the status of workspace, you will find the prompt file is updated, but the update is only in workspace, not to staging area.

Mo language as the saying goes, everything is always empty. Ideal reality, the heart without distractions feet steadfast. Who has no storm, when the rain, keep the clouds open to see the moon Ming. Flowers open again but wandering, regrets Mo make this life stay.

Similarly, with the add, commit operation, we can put the file update first to staging area, and then from the staging area submitted to repo.

Note that only updates that are add to staging area will be submitted into repo. before submission, if the workspace file is modified, but not added to the staging area, then the content submitted into the repo is only staging area the current content, workspace the modified part will not be submitted into the repo.

Git local repository

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.