The essence of the essence! It is understood by a simple example Git

Question 1: Why should this Git?
Personal understood: developers Linus send by mail to the source code files I have written, it will be merged by Linus by the code manually. Everyone can not have a local source database server, so no longer totally dependent on the source database server, makes publishing and merge source code easier. So git born!

Examples: GitHub is a hosted service software source code version control via Git, the user can create a public code repository for free. (Programmers know it!)

Question 2: What is Git?
A: Git is a distributed version control software, and CVS, Subversion centralized version control for a class of different tools, it uses a distributed repository of practice, no server-side software, version control can operate, making the source code the dissemination and exchange extremely convenient!

A: Git service running idea
text:
1. Modify the data file in the working directory.
2. The snapshot file into the staging area.
3. The staging area is a snapshot of the file submitted to the Git repository.
image:
Here Insert Picture Description

Two: Git service base command:
the personal user name and e-mail address:
git config --global user.name "the Name"
git config --global user.email "root @ Email"
submit data:
git the Add the Readme.txt
will be temporarily submission of documents to the memory area of the Git version repository:
git the commit -m "explanation"
to view the current version of Git repository in the state:
git status

Three: Getting Git server
Git is a distributed version control system, as long as we have a primitive Git repository, you can let other hosts clone our original version of the warehouse, making a Git repository version can be distributed simultaneously to a different host above.
1. Install git Service
[root @ CAQ ~] # yum install git
2. Create a Git repository version, should take .git suffix:
[root @ CAQ ~] # mkdir caq.git
3. modified version of Git repository owner and All groups
[the root CAQ @ ~] # chown -Rf Git: Git caq.git /
4. initialization Git repository version:
[CAQ the root @ ~] # CD caq.git /
[the root @ CAQ caq.git] # Git - bare init Initialized empty Git repository in /root/caq.git/
5. Git repository server has been deployed at this time, but can not share them with others. There is a need to limit agreements. Guessed it, it is the ssh protocol!
Ssh key generated on the client
[CAQ the root @ ~] # ssh-keygen
Generating public / RSA Private Key pair.
The Enter to Save File in Which The Key (/root/.ssh/id_rsa):
the Created Directory '/ the root /. ssh '.
Passphrase the Enter (empty passphrase for NO):
the Enter passphrase Same, Again:
. Your Identification has been saved in /root/.ssh/id_rsa
Your public Key has been saved in /root/.ssh/id_rsa.pub.
At The Key Fingerprint IS:
65:. 4A: 53 is: 0D: 4F: EE: 49: 4F: 94: 24: 82: 16:. 7A: dd: 1F: 28 [email protected]
of The Key Image apos randomart IS:
± - [the RSA 2048] - - +
|. + .o OO.o |
.. | .oo * + |
| ... O + E * |
. | = O = + |
| S OO |
| |
| |
| |
| |
± --- ------------- +
will be passed to the client's public key Git server:
[root@caq ~]# ssh-copy-id 192.168.10.10 [email protected]’s password: Number of key(s) added: 1 Now try logging into the machine, with: “ssh ‘192.168.10.10’” and check to make sure that only the key(s) you wanted were added.

6. Now the client can clone version of the service end of the warehouse.
[root @ caq ~] # git clone [email protected]: /root/caq.git Cloning into 'caq' ... warning: You appear to have cloned an empty repository.

7. Initialization Git working environment:
[root @ CAQ ~] # git config --global user.name "Liu Chuan" [root @ CAQ ~] # git config --global user.email "[email protected]" [ CAQ ~ @ root] # vim git config --global core.editor
8. submit to the Git repository version of a new file:
[root @ CAQ CAQ] # echo "the I AM Fine"> the Readme.txt
[root @ CAQ CAQ] git the Add the Readme.txt #
[root @ CAQ CAQ] Status git #
# the On Branch Master
#
# Initial the commit
#
# Changes to BE committed:
# (use "git RM --cached ..." to unstage)
#
# new new File: the README .txt
#
[@ CAQ CAQ the root] # Git the commit -m "The Clone the Git Repository"
[Master (the root-the commit) c3961c9] The Clone the Git Repository
the Committer: the root
. 1 File changed, Insertion. 1 (+)
create mode 100644 readme.txt
[root@linuxprobe caq]# git status
# On branch master
nothing to commit, working directory clean

9. The server sends the file to
[the root @ CAQ CAQ] # Git the Add Remote Server [email protected]: /root/caq.git
[the root @ CAQ CAQ] -u # Git Push Server Master
a Counting Objects:. 3, DONE.
Writing Objects: 100% (3/3), 261 bytes | 0 bytes / S, DONE.
the Total. 3 (Delta 0), the Reused 0 (0 Delta)
the To [email protected]: /root/caq.git
[new new Branch] Master -> Master
Branch up to the SET Master Track Master from remote Branch server.
10. Check whether the remote server's repository of documents sent by the client (and I am a clone, of course, you can switch directly to the server to view shared repository ) [the
root @ CAQ CAQ] CD # ... / ~
[CAQ the root @ ~] clone # [email protected] Git: /root/caq.git
Cloning INTO 'CAQ' ...
Remote: a Counting Objects:.. 3, DONE
Remote: . 3 the Total (Delta 0), the Reused 0 (0 Delta)
Receiving Objects: 100% (3/3), DONE.
[root@caq ~]# cd caq/
[root@caq caq]# cat readme.txt I am fine

git content knowledge is something that many, many people see this and if I am, then the remaining knowledge of it. Lazy, hee hee hee.

Published 18 original articles · won praise 16 · views 2993

Guess you like

Origin blog.csdn.net/qq_45714272/article/details/105031710