About version control:
A long time ago, people suffered from version management for the code they had written. After a while, they often tried to restore the code they had previously written, but they forgot where they lost it, some people use the method of naming files with time suffixes to facilitate later maintenance. However, this process is very troublesome and takes a long time, I will also forget when to save the file for use, and in case my computer breaks down and causes file loss, the previous efforts should start from scratch. So people want to have a good version control system to control the version and facilitate backtracking.
---- Below is a piece of instruction on version control that was excerpted from the git-scm.com (a wizard book about git, online with http://git-scm.com/book ,):
The general meaning is that the version control system (VCS) is a system that can save information of files in different time periods and can be traced back, some people studied the version control system a long time ago. That is, the version control system is local.
The version control system has been developed for a long time. It is mainly divided into a central version control system called CVCs (centralized version control system) and a distributed version control system, it is called DVCs (distributed version control system ). The two systems have their respective disadvantages:
The advantages of the central version control system are obvious. It has a set of standardized management processes and many software supported on the market. However, its disadvantages are also obvious, all its versions are controlled on one service host. If the server crashes one day, the hope of file recovery can only be found from the sub-machine where the files have been downloaded from the server, however, there is no guarantee that the sub-opportunity will completely copy the project files, and there is a high risk of file loss. There are many central version control systems, such as CVS, subversion, and perforce. Currently, the company uses subversion.
In contrast, the advantage of distributed version control is that it obtains a complete copy from the code repository instead of checking out some files. Each local host is a code repository, any device that crashes can obtain the latest update content from other devices. In addition, distributed version control also features that most operations are performed locally, and can be saved to the local repository even if there is no network, and pushed once when there is a network, this gives the distributed version control system great freedom. But it also has its disadvantages. Why do companies use central version control software instead of distributed version control? This is because the distributed version control system was originally developed by the open-source community. For code sharing, the copied project was a complete copy, and the company kept it confidential, permission protection is required for different files of the project. For example, XX files can only be maintained by the Project Department, XX file Development Department manages the files, and other departments cannot modify the files, this file is not even visible when you log on to the version control software system. The distributed version control system software includes git, mercurial, bazaar, and darcs.
The following is a comparison between a central version control system (on) and a distributed version control system (on.
It is not hard to see that the distributed version control system has higher security. Multiple copies of files are ensured, so that all files will not be lost due to the fault of a certain machine. Even if the host crashes, the latest update files can be obtained from the sub-warehouse below.
---- About git
This article describes in detail the introduction and installation of git. Git is developed by Linus Torvalds, a Linux developer. The features of git include:
It mainly refers to git's fast, simple design, support for parallel development, full distribution, and ability to effectively handle some outstanding features such as large projects. For details about git, refer to Google.
The following describes how to install git. Currently, the open-source community is popular with code hosting on GitHub. This is an open-source code hosting platform. You need to apply for an account to log on, after logging on to the code can be maintained, the need can go to the https://github.com site to apply for a git account.
The following uses GitHub as an example to create a git project.
The process is relatively simple:
Step 1: Click sign up for GitHub.
Go to the following page and enter the complete user information. The email here must be valid. You need to verify it later. Click create an account.
Next, select your plan and have free services. If you need additional private space, you can purchase additional services.
The registration content here is relatively simple. You only need to register an account and activate it by email. Now you can log on to GitHub and create a repository according to the wizard. Click new
Enter the correct repository name and click Create repository.
After the creation is successful, you can jump to the following interface:
After creating your repository working directory, you can see the following instructions on how to create a new repository and push resources to repository using the command line.
Now has completed the GitHub account registration, the following is to download the GIT client, GitHub client: https://github-windows.s3.amazonaws.com/GitHubSetup.exe, Windows users are recommended to download this link, the installation configuration is more convenient.
For Mac or Linux users, refer to this page: http://git-scm.com/book/en/Getting-Started-Installing-Git
If you need to go to the official site to download git client, you can click the link: http://git-scm.com/download to download the corresponding version of the operating system.
For Windows systems, there are two shortcuts to the desktop after download and installation:
The first is the Shell Interface of the UNIX environment, and the second is the GitHub interface. We recommend that you use the Shell Interface of git. The Cui of UNIX is very powerful and the operations will be very quick in the future.
First, go to the shell interface and set the user name and email address:
Run the following two commands:
git config --global user.name "Enter your username here" git config --global user.emil "Enter your E-mail address"
These two commands are used to set the user. Name and user. Email parameters in your code parameter gitconfig file. Later, you can use this identity to get the repository code and push the code to the repository.
Git comes with a tool calledgit config
That lets you get and set configuration variables that control all aspects of how git looks and operates. These variables can be stored in three different places:
/etc/gitconfig
File: contains values for every user on the system and all their repositories. If you pass the option--system
Togit config
, It reads and writes from this file specifically.
~/.gitconfig
File: specific to your user. You can make git read and write to this file specifically by passing--global
Option.
- Config file in the GIT directory (that is,
.git/config
) Of whatever repository you're currently using: specific to that single repository. Each level overrides values in the previous level, so values in.git/config
Trump those in/etc/gitconfig
.
On Windows systems, git looks for.gitconfig
File in$HOME
Directory (%USERPROFILE%
In Windows 'Environment), which isC:\Documents and Settings\$USER
OrC:\Users\$USER
For most people, depending on version ($USER
Is%USERNAME%
In Windows 'Environment ). it also still looks for/etc/gitconfig, although it's relative to the msys root, which is wherever you decide to install git on your windows system when you run the installer.
Source: http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup>
The above section provides a detailed explanation of gitconfig. Many environment variables are configured in gitconfig. These variables can be found in the following three places in Linux:
1. In the/etc/gitconfig file: when using the GIT config command, if the -- system parameter is used, the file is read and written, which is applicable to all users of the system.
2 .~ /. Gitconfig: Users familiar with Linux must know this ~ It indicates the user's home directory. The parameter configured in the user's home directory is only applicable to the current user, because Linux is a multi-user operating system, therefore, configuring parameters for individual users is a good solution. Using the GIT config -- Global Command is to operate the gitconfig file of the current user.
3. The third is the. Git/config file under the current project folder. This file only affects the current project. If you use git config without adding parameters, you can read and write the gitconfig file of the current project.
The gitconfig file in Windows is the. gitconfig file in the current user's main directory by default, depending on the situation.
The priority of the preceding configuration file is from low to high.
You can use
Git config -- list
To view the information of a single parameter, run the following command:
Git config enter you argument name # such as git config user. Name
Step 2: Initialize the repository in the working directory:
Use the following command to initialize your Repository
Git init
To view the current status of your repository, run the following command:
Git status
It obtains the details of the current code repository.
In git, resources are stored in three places, working directories, temporary directories, and git libraries.
When you edit a file locally, the Code is not saved. When you use the GIT add command to add the file to your repository, the file is saved, when a network is used and you use commit and push it to repository, it will be stored in the GIT version library and a snapshot of all resources will be saved (here the snapshot refers, when you use git to push resources, the Digest of the project file structure is generated based on the SHA-1 algorithm. It is a string consisting of 40 characters, git determines whether the submitted resources have been updated based on it ).
Step 3: Get a copy of the project from the code repository:
Use the following command to obtain the latest code project from the GIT Library
Git clone https://github.com/<your username>/<file name of the project you want to copy>. Git
In this way, your local code repository contains a folder named after your project file name. Git supports many protocols, including the GIT: // protocol. Previously, the https: // protocol was used. You can also use username @ servername:/path. git SSH commands. These three protocols have their own advantages. You can view the https: // protocol and use username @ servername:/path. git SSH command, these three protocols have their own advantages, need to know can view http://git-scm.com/book/en/Git-on-the-Server-The-Protocols
Step 4: Submit the code to the repository:
After editing some files, git marks these files as modified. We gradually put the files in the temporary storage area and finally submit them to the GIT repository. The following shows the File status cycle:
After editing a file, you can use the GIT addtracking file to save the modified test.txt file under the folder of our project. The content is Hello git !, Use the following command to trace the file
git add test.txt
After running this command, the file is saved. Now we need to submit our code to the local repository git commit. This command will submit the updates we have made, after executing this command, an editor is opened by default, which is usually VI. You must add a description of the file. If you want to add instructions directly on the command line, you can add the-M parameter.
git commit -m "Enter you summary"
After the above statement is executed, the update will be submitted directly without opening the editor and adding a description.
Step 5: push to the GIT Repository:After updating the file, we need to push it to the GIT repository. First, use the following command to view the GIT remote repository information. By default, the GIT remote repository has an origin repository, you can also manually add a repository.
Git remote add your repository name https://github.com/<your username>/<your project file name>. Git
After the preceding statement is executed, a custom remote library is added to GitHub, which performs the same operations as the default remote library. Now we push the project file to the default remote library. Git push origin master the above Code pushes the files in the local repository to the remote repository of GitHub. The master here is the default name of our local repository, you can also customize the name of the local repository. The default name is generally used. We can also use the following command to capture the GIT fetch [Remote-name] logs file of the remote database. The above is the simplest GitHub code hosting process. Finally, the article is attached to the main reference source: http://git-scm.com/book (pro git) http://blog.csdn.net/gavincook/article/details/11992827