First, Git introduction
Git is a free, open source distributed version control system
Characteristics:
Git is an open source distributed version control system that works,
High-speed processing from very small to very large project version management
Second, git installation
Linux: Download, install
1. Installing the System environment
CentOS 6.9 64-bit
Version 2.git
2.8.0
3. Installation Steps
(1) Download from GitHub website
https://github.com/git/git/releases?afer=v2.9.1
or perform the installation directly on Linux
wget https://github.com/git/git/archive/v2.8.0.tar.gz
Git installation dependencies
Yum-y Install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-extutils-cbuilder Perl-extutils-makemaker
(2) Decompression: TAR-ZXVF v2.8.0.tar.gz
(3) Compile: Make prefix=/application/git all
(4) Run: Make Prefix=/application/git Install
(5) Uninstall: Yum remove git uninstall git
window: Download, install
1. Installing the System environment
Window 10 64-bit
Version 2.git
2.12.1-64bit
3. Installation Steps
(1) Login website Download installation package: https://git-for-windows.github.io/
Third, git configuration
Basic configuration, SSH key pair configuration
1. Configure user name (referenced at commit)
git config--global user.name ' Xningge '
#请把xningge替换成自己的用户名
2. Configure the mailbox (referenced at commit)
git config--global user.email "[Email protected]"
#请把 [email protected] to replace your own user mailbox
3. Other configurations
git config--global merge.tool "KDIFF3"
#要是没安装KDiff3就不用设这一行
git config--global core.autocrlf false
#让Git不要管Windows/unix the line break.
2. Encoding Configuration
git config--global gui.encoding utf-8
#避免git status displays a garbled Chinese file name
The window also needs to be configured:
git config--global core.ignorecase false
3.git SSH key pair configuration
(1) under Linux command line, or on Windows git Bash Command Line window key input:
Ssh-keygen-t rsa-c "[Email protected]"
(2) Then return all the way, do not enter any password, etc., generate SSH key pair
(3) Ssh-add ~/.ssh/id_rsa
(4) Cat ~/.ssh/id_rsa.pub
Note: Could not open a connection to your authentication agent appears when executing ssh-add
Perform eval ' ssh-agent ' (the one on the ~ key) before performing an error on the Ssh-add ~/.ssh/rsa report header
And then execute Ssh-add ~/.ssh/id_rsa success Ssh-add-l There's a new addition rsal
(4) Copy the contents of the public key to the Clipboard
(5) I use the Oschina of the Gitlab, specific according to their own circumstances to set
(6) Login to the upper right corner of the Gitlab profile
(7) Enter the personal SSH public key configuration, add the newly pasted copy to confirm the submission
Four, git authentication
1.Linux: Execute git--version command, version information appears, installation is successful
2.window: Execute git--version command, version information appears, installation is successful
Five, git commands
1. Switch branches: git checkout branch name
2. Pulling; git pull
3. Commit: Git push
4. View branches: Git branch
Common git commands
Git init
git status
git Add.
Git commit-am ' first commit init project '
git remote add origin [email protected]:xningge/jintao.git
Git remote RM origin
git remote add origin [email protected]:xningge/jintao.git
Git push-u Origin Master
Git pull
Git push-u Origin Master
Git push-u-F Origin Master
Git branch
Git branch-r
Git Checkout-b v1.0 origin/master
Git push Origin Head-u
Git installs and uses Linux systems and window systems