[Git Learning 1] How git works

Source: Internet
Author: User
Tags version control system git commands

Tag: git

1. Background: git is a popular version management software. It has been used only by SVN and git. Although git has been used for a long time, it has not been studied in depth. This week, I plan to read progit and have an in-depth summary of git, in addition, summarize some of the main git commands to facilitate future study and use.
2. A Brief History of git reads the first chapter of progit, which is impressive as follows. 1. The bottom layer of git is the database, so that we can understand the basic principles of git and save the project snapshot to the database according to the code. 2. Git was first developed by developers in the Linux community! 3. The main advantage of git is that it is a distributed version control software, that is, in addition to recording each code version on the server, each terminal also has a. Git file on its own computer to record the complete project.
3. Git and SVN comparison

This part is still a summary of reference online, I feel very good, from http://www.oschina.net/news/12542/git-and-svn

1. Git is distributed, and SVN is not:

This is the core difference between git and other non-distributed version control systems, such as SVN and CVS. If you can understand this concept, you will be half done. You need to make a statement that git is not currently the first or only distributed version control system. Some other systems, such as bitkeeper and mercurial, also run in distributed mode. But git is doing better in this regard and has more powerful features.

Git and SVN have their own centralized version libraries or servers. However, git is more inclined to be used in the distributed mode, that is, each developer will clone a version library on their own machine after chect out code on the central version Library/server. It can be said that if you are stuck in a location that cannot connect to the network, like on the plane, in the basement, in the elevator, you can still submit files and view historical version records, create a project branch. For some people, this seems to be of little use, but when you suddenly encounter an environment without a network, this will solve your major troubles.

Similarly, this distributed operation mode is also a huge gift for the development of open-source software communities. You do not have to make a patch package as before and send it by email, you only need to create a branch and send a push request to the project team. This keeps your code up to date without being lost during transmission. Github.com is an outstanding case.

It is rumored that the future version of subversion will also be based on the distributed mode. At least not yet.

2. Git stores the content in metadata mode, while SVN stores the content by file:

All resource control systems hide the object metadata in a folder such as. SVN and. CVs. If you compare the size of the. Git directory with that of. SVN, you will find that they are quite different. Because the. Git directory is a clone version library on your machine that owns everything on the central version library, such as tags, branches, and version records.

3. Git branch and SVN branch are different:

The Branch is not special in SVN, that is, another directory in the version library. If you want to know whether a branch is merged, You need to manually run the command SVN propget SVN: mergeinfo like this to check whether the code is merged. Thanks to Ben for pointing out this feature. Therefore, some branches are often missed.

However, it is quite simple and interesting to process git branches. You can quickly switch between several branches in the same working directory. You can easily find unmerged branches. You can easily and quickly merge these files.

4. Git does not have a global version number, but SVN has:

So far, this is the biggest feature missing from git compared with SVN. You also know that the SVN version number is actually a source code snapshot of any corresponding time. I think it is the biggest breakthrough from the evolution of CVS to SVN. Because git and SVN are different in concept, I don't know what features in git correspond to them. If you have any cable, please share it with you in your comments.

Update: Some readers point out that we can use git's SHA-1 to uniquely identify a code snapshot. This cannot completely replace the number version that is easy to read in SVN. However, the purpose should be the same.

5. The content integrity of git is better than that of SVN:

Git uses the SHA-1 hash algorithm for content storage. This ensures the integrity of the Code content and reduces the damage to the version library in case of disk or network problems.


/********************************

* This article is from the blog "Li bogarvin"

* Reprinted please indicate the source: http://blog.csdn.net/buptgshengod

**************************************** **/

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.