Git (1)-basic overview

Git (1)-basic overview

Install the latest version of Git on CentOS

The Git version in the yum source repository is not updated in time. The latest version of Git is 1.8.3.1. If you want to install the latest version of Git, you can only download the source code and install it.

yum info git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name: git
Arch: x86_64
Version: 1.8.3.1
Release: 14.el7_5
Size: 4.4 M
Repo: updates/7/x86_64
Summary: Fast Version Control System
URL: http://git-scm.com/
License: GPLv2
Description: Git is a fast, scalable, distributed revision control system with an
            : unusually rich command set that provides both high-level operations
            : and full access to internals.
            :
            : The git rpm installs the core tools with minimal dependencies. To
            : install all git packages, including tools for integrating with other
            : SCMs, install the git-all meta-package.

git has released version address https://github.com/git/git/releases

image.png

Dependent library installation

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker

Uninstall the low version of Git

yum remove git

Download the new version of the Git source package

wget https://codeload.github.com/git/git/tar.gz/v2.18.0

unzip files

tar -xzvf v2.18.0 -C ~/app/

Install git

cd ~/app/git-2.18.0
make prefix=/usr/local/git all
make prefix=/usr/local/git install

Add to environment variables

echo "export PATH=$PATH:/usr/local/git/bin" >>/etc/bashrc
source/etc/bashrc

View version

git --version
#git version 2.18.0

Configure user information

  1. git config --system: Configure the general configuration of the warehouse for the entire system. The configuration information is in the/etc/gitconfig file (the information configured with --system can be used by all users under the Linux system)
  2. git config --global: Configure the general configuration of the warehouse for the current user. The configuration information is in the/.gitconfig or/.config/git/config file (the configuration information is under the current user and cannot be used under the guest user)
  3. git config --local: The --local parameter can default to the current warehouse configuration information, which is in the .git/config file of the current warehouse.

Specific configuration user information:

git config --system/--global/--local user.email "you@example.com"
git config --system/--global/--local user.name "Your Name"

View configuration list

 git config --local -l #View the warehouse-level configuration list
 git config --global --list #View the global configuration list
git config --system -l # View the system-level configuration list

Configure global ignore files

In addition to defining the .gitignore file in the project, the .gitignore file that defines the global Git can also set the global git .gitignore file to manage the behavior of all Git projects. This method is not shared between different project developers, and belongs to the Git application level behavior on the project. This method also requires the creation of a corresponding .gitignore file, which can be placed in any location. Then use the following command to configure Git:

# git config --global core.excludesfile ~/.gitignore

First of all, we must emphasize that the full file name of this file is ".gitignore". Note that there is a "." at the beginning. Generally speaking, every Git project needs a ".gitignore" file. The function of this file is to tell Git which files do not need to be added to version management.

Modify the default editor of git to Vim

The default editor nano of git in linux, nano is used to edit the submitted page, the exit method is: Ctrl + X, then enter y and then press Enter, you can exit. If you want to change the default editor nano to git Method one, Set core.editor in the GIT configuration: git config --global core.editor vim Method two, modify the .gitconfig file. Add editor = vim in core. In this way, vim will be automatically used as the editor when using git in the future

Create SSH Key

$ ssh-keygen -t rsa -C "youremail@example.com"

The key type can be specified with the -t option. If not specified, the RSA key for SSH-2 will be generated by default. Rsa is used here. At the same time, there is a comment field in the key. Use -C to specify the specified comment, which can facilitate the user to identify the key and point out the purpose of the key or other useful information. So enter your own email address here or anything else. After the input is completed, the program also asks to input a passphrase, empty means there is no passphrase. Then you will be asked to enter the password twice, empty means there is no password. Enter 3 times to complete the current step.

$ ssh-keygen -t rsa -C "yangyucug@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/baxiang/.ssh/id_rsa): 
Created directory'/home/baxiang/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in/home/baxiang/.ssh/id_rsa.
Your public key has been saved in/home/baxiang/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Y4bxF3Aylak4SjOgmDnLaQODZFFPBHp8fuKbWkUTyYM yangyucug@gmail.com
The key's randomart image is:
+---[RSA 2048]----+
| .ooooo.=.oo |
| o+ oE +.=o |
|== + o.+... |
|X. * ++o. |
|o+.. *.+S. |
|.= o +oo |
|.. o |
|. o |
| ..o |
+----[SHA256]-----+
Reference: https://cloud.tencent.com/developer/article/1437084 Git (1)-Basic Overview-Cloud + Community-Tencent Cloud