Git and SCM intro

Source: Internet
Author: User
Tags how to use git

Tag: git

Why do we need SCM (software configration Management)Software Configuration Management (SCM) mainly solves two problems: 1. Software Version Management 2. team collaboration management. Software Version ManagementDuring software development, code and documents are constantly changing. The SCM tool can help you record this forward track, including code, document changes, and reasons for changes, this allows you to clearly control the evolution of your project. The main version of the software has only one track, but there will be many forks on this track, that is, the so-called branch. Next we will introduce the branch based on git version control.
Team Collaboration ManagementGenerally, a project is not developed by only one person. If there is cooperation, the results of the merger will exist. Without SCM, these merging processes will be completely operated manually, which is extremely inefficient. Team collaboration is mainly implemented through the branch. The function of the project is divided into a branch, and a Member is used to implement the branch. Finally, the Branch is merged into the main branch of the project. Of course, multiple members are allowed to collaborate on one branch (similar to concurrent programming on the surface, but the strategy is different from concurrent programming. Concurrent Programming mainly uses pessimistic locks, it is used to prevent conflicts. SCM adopts an optimistic lock policy. If there is no conflict, manually resolve the conflict when the conflict occurs ).
Common SCM toolsCommon SCM tools include CVs, SVN, and git. The first two are centralized and git is distributed. Centralization means that each submission needs to be transmitted to the server, so you need to use the network, and performance problems may be caused by too frequent submission, but because the local version library does not exist, therefore, the advantage is simplicity. Distributed means that in addition to the server, your local version Library also exists. You can record the version from the network, and then submit it to the public version library on the server through the network, therefore, the number of submissions can be reduced to a certain extent, and the overall performance is higher. In addition, it also allows some special usage, for example, as long as you have not submitted the version to the public version library, you can safely switch your project to a previous version (in a centralized version control system, others can download newer code, so it is not easy to do this operation ). There is no free lunch here, and the distributed features have also brought some complexity improvements to git (mainly the one-time learning cost, which is easy to use later ). Below we will briefly introduce some common SCM usage through git. For details about how to use git, see the GIT column in the blog.
Git A picture illustrates version Evolution
There is a project in the picture starring in the version. In git, it is called Master Branch (main branch), which is usually put in the public version Library (GitHub or gitlab ). To modify the code of the main branch, you can use either of the following methods: 1. you can directly clone the code in the public version Library to the local version library, modify the code, and submit it again. It corresponds to the black line above the main branch in the figure. 2. Apply for another branch on the main branch, complete all the code modifications on the Applied branch, and then merge them to the main branch, which corresponds to the Blue Line in the figure. However, the fate of all branches may not always be merged into the main branch. For example, to release a version of the main branch, we can pull a branch on the main branch, then, make the final modification before the release. After the release, the branch becomes useless and corresponds to branch B in the figure. The above figure only describes the general features of SCM, and git is characterized by the fact that before each commit to the public version Library (in master branch and branch, local repository can be submitted multiple times locally, that is, the local repository can be submitted to the public version library after a longer distance before recording its own history.
Function of BranchFor more information about the purpose of using the branch and Its Application in git, see http://blog.csdn.net/troy#/article/details/39853321.
Functions of tagsTags are used to record milestones (important moments) of a project, which are more conspicuous than the history of commit. Tags are often used to mark the final moment of a branch. A branch is no longer alive, And a tag is evidence of its existence.
Benefits of setting a buffer in gitGIT also adds a layer to the local version library and local code, known as the staging area ). After the local code is modified, you can add it to the temporary storage area. After adding the code to the temporary storage area multiple times, you can submit the code to the local version library at a time. This reduces the frequency of exposure to version libraries, reduces the number of version updates (the number of historical records), and facilitates functional division, the update submission performance is improved in general (you don't have to worry about the performance of adding to the temporary storage area, because the add operation only adds the files to be updated to the index, in commit, you only need to read these indexes to know the files to be submitted ).


Personal experience Do not forcibly remember commandsI always think that we should not forcibly remember some commands, such as git, VI, and Linux... there are two reasons: 1. what we need is the execution effect after the command, not the command itself. For mature tools or systems such as git and Linux, as long as you can think of operations that conform to the normal logic, almost all of them provide the corresponding implementation. If you want to use them, you can directly query them online. For memory nutrition ing between this function and commands is extremely low, you should focus on improving the global grasp, rather than the command itself. 2. for commonly used operation commands, you do not need to remember them, but you can also remember them. For those commands that are used once a lifetime, just let them go...
Flexible conversion between commands and guisI have always been skeptical about statements that fully boast command operations. It seems that full command operations in various environments can display my identity as a big bull. The command has good command, and the GUI has good GUI. In some scenarios, you can use commands to perform operations with smaller functions or deeper depth to achieve the destination. For example, if you want to use git to submit the code after modification, you may not move one hand over the keyboard, and then open the GUI on the taskbar, move the mouse over the face, find the space input information, and then click Submit. Instead, run the command (Windows) tab + ALT to git bash, and then enter git commit-M "XXX"-. The two operations, in summary, the results are clear. For operations like git diff, you may need to use the GUI when there are many changes. Therefore, you can flexibly switch between commands and guis to improve your work efficiency.

Git and SCM intro

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.