First: git is a lightweight file system created by the father of Linux. Currently, most of it is used as version control, the basic principle of version control is to sacrifice disk space (save all historical versions, rather than save the difference) to improve performance, and at the same time, it is easy to create branches (conducive to cooperative development ). Git has three
First:GitIntroduction
Git is a lightweight file system created by the father of Linux. Currently, most of it is used as version control. The basic principle of version control is to sacrifice disk space (save all historical versions, instead of saving the amount of difference) to improve performance, it is easy to create branches (conducive to cooperative development ). Git contains three regions (1, Repository 2, Working directory 3, Staging area/IndEx), Repository (the default is. git is the name directory, which means you can customize your own name. It can be used as a repository or database, because all the code will be stored in it in the future. Working directory is easy to understand, is the development environment (such as the Directory used to write code), Staging area
/Index is an intermediate state (code is submitted from Working directory to Repository. DetailsCommandThe process is: gitDd. Another command is used to submit code from Working directory to Staging area/Index: git commit-m "comment" indicates that the Quick Command for submitting the two steps from Staging area/Index TO Repository is: git commit-. In addition, git contains four objects, blob,TrEe and tag, commit (blob andTree(Tree corresponds to commit, and tag corresponds to commint). In fact, the git structure is a tree structure composed of these objects, the version of each project is actually saved in git in the form of commit, and commit points to the tree. blob is like the leaf of the tree, which is actually the entity that stores the data. In addition, git also contains the pointer HEAD and bra.NcE. The unique header pointing to commit.
To learn more about git, go to the Web search page.
2. Download and install git
The downloaded website can be downloaded from the official website. Here, git-1.7.7.4.tar.gz is downloaded.
[Root @ localhost ~] # Tar zxvf git-1.7.7.4.tar.gz
[Root @ localhost ~] #CdGit-1.7.7.4
[Root @ localhost git-1.7.7.4] #./configure
[Root @ localhost git-1.7.7.4] # make & make install
After installation, check the default installation directory when. configure is not added.
[Root @ localhost ~] #WhichGit // This PATH is in the PATH, so you do not need to add
/Usr/local/bin/git
In this way, git is successfully installed.
Third: basic configuration of git (root Login here)
[Root @ localhost/] #Mkdir-P/git/project
[Root @ localhost/] # cd/git/project/
[Root @ localhost project] # git config -- global user. name 'ethnicitybeta'
[Root @ localhost project] # git config -- global user. email 'ethnicitybeta @ 126.com'
The Global configuration is actually written into the git configuration file in the user's home directory.
[Root @ localhost project] #Cat~ /. Gitconfig
[User]
Name = ethnicitybeta
Emal = ethnicitybeta@126.com
Email =
[Root @ localhost project] # vim main. c // create a test file
Hello ethnicitybeta !!!
[Root @ localhost project] # git init // git Initialization
InitializEdEmpty Git repository in/git/project/. git/
[Root @ localhost project] #Ls-Al
Total 32
Drwxr-xr-x 3 root 4096 Nov 27.
Drwxr-xr-x 3 root 4096 Nov 27 ..
Drwxr-xr-x 7 root 4096 Nov 27 :38. git
-Rw-r -- 1 root 23 Nov 27 0:37 main. c
The following section shows the local settings relative to the global settings.
[Root @ localhost project] # git config user. name 'ethniciy'
[Root @ localhost project] # git config user. email 'ethnicity @ 126.com'
[Root @ localhost project] # cat. git/config
[Core]
RepositoryfoRmAtversion = 0
FileMode = true
Bare = false
LogallrefupDateS = true
[User]
Email = ethnicity@126.com
Name = ethnicity
Fourth: A git instance
[Root @ localhost project] # vim main. c // create a test file
Hello ethnicitybeta !!!
[Root @ localhost project] # git init // git Initialization
[Root @ localhost project] # git add. // add to git
[Root @ localhost project] # ll. git // The index shown below is Staging area
Total 72
-Rw-r -- 1 root 23 Nov 27 0:38 HEAD
Drwxr-xr-x 2 root 4096 Nov 27 branches
-Rw-r -- 1 root 143 Nov 27 0:41 config
-Rw-r -- 1 root 73 Nov 27 :38 description
Drwxr-xr-x 2 root 4096 Nov 27 hooks
-Rw-r -- 1 root 104 Nov 27 index
Drwxr-xr-x 2 root 4096 Nov 27 0:38 info
Drwxr-xr-x 5 root 4096 Nov 27 objects
[Root @ localhost project] # git commit-m'1st commit '// submit and generate the first commit
[Master (root-commit) 96f025b] 1st commit
1 files changed, 1 insertions (+), 0 deletions (-)
Create mode 100644 main. c
[Root @ localhost project] # rm-rf main. c // simulate a file loss
[Root @ localhost project] # git checkout-f HEAD // retrieve the lost file
[Root @ localhost project] # ls
Main. c
Conclusion: The concept of version control has been put into use before. The only concept of the term is svn, which has not been studied yet. It is very easy to use with git, here is a systematic learning record for use at work. I would like to thank Mr. Xiao Bu for his selfless teaching.