源碼安裝
訪問地址:https://git-scm.com/download/linux
https://mirrors.edge.kernel.org/pub/software/scm/git/找到最新版本的tar.gz包
本次下載git-2.20.1.tar.gz安裝git的依賴項
[root@localhost ~]# yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[root@localhost yum.repos.d]# yum -y install gcc perl-ExtUtils-MakeMaker移除已安裝的git
[root@localhost ~]# yum remove git解壓安裝包
[root@localhost ~]# tar -zxvf git-2.20.1.tar.gz進(jìn)入解壓目錄,預(yù)編譯git
[root@localhost ~]# cd git-2.20.1
[root@localhost git-2.20.1]# ./configure --prefix=/usr/local/git編譯并安裝git
[root@localhost git-2.20.1]# make && make install將git的腳本軟連接到/usr/bin/目錄下
[root@localhost git-2.20.1]# ln -s /usr/local/git/bin/* /usr/bin/檢測是否安裝成功
[root@localhost git-2.20.1]# git --version
全局配置
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
與某遠(yuǎn)程倉庫關(guān)聯(lián)
創(chuàng)建一個新倉庫
git clone git@gitlab.whenling.com:root/blank-project.git
cd blank-project
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master在已存在的文件夾下
cd existing_folder
git init
git remote add origin git@gitlab.whenling.com:root/blank-project.git
git add .
git commit -m "Initial commit"
git push -u origin master在已存在的倉庫下
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.whenling.com:root/blank-project.git
git push -u origin --all
git push -u origin --tags
本地與遠(yuǎn)程倉庫不一致時拉取
git pull origin master --allow-unrelated-histories