安裝git
//添加源
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
git --version
clone 項(xiàng)目
git clone xx@xxx:xxx
git配置
命令行(--global)執(zhí)行后生成的配置文件位于: ~/.gitconfig
# 指定 user.email
git config --global user.email "jh.zhu@xxx.com"
# 指定 user.name
git config --global user.name "zhujh"
# 指定編輯器為vim
git config --global core.editor "vim"
https用戶名/密碼
本地保存https用戶名/密碼(被保存到~/.git-credentials)
# 保存用戶名膀息、密碼般眉,在下一次git命令輸入用戶名/密碼后齐鲤,會被保存到~/.git-credentials
git config --global credential.helper store
# ==>或者直接修改~/.git-credentials文件
https://jh.zhu@xxx.com:xxx_password@xxx_domain
// 中文顯示\345\276\205\346\225\264\347\220
// core.quotepath設(shè)為false的話芦拿,就不會對0x80以上的字符進(jìn)行quote吨艇。中文顯示正常掘剪。
git config --global core.quotepath false
ssh私鑰(避免每次輸入密碼)
下載之前保存的ssh 私鑰,拷貝到 ~/.ssh目錄下米母,文件名 id_rsa(可以使用其他名字斩祭,需要配置汹碱,后續(xù)補(bǔ)充)
備注:如果之前沒有ssh私鑰裁替,需要新生成项玛。
#郵箱可以隨便填, 生成文件默認(rèn)是 .ssh/id_rsa
$ ssh-keygen -t rsa -C "xx@xx.com"
如果ssh私鑰有密碼弱判,為了避免每次push輸入密碼襟沮,可以將其添加到ssh-agent的高速緩存中:
ssh-agent bash
ssh-add ~/.ssh/id_rsa
多個ssh的key配置:參考:git 配置多個SSH-Key
~/.ssh文件夾下創(chuàng)建config文件:
# gitlab
Host gitlab.com
User git
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
測試
$ ssh -T git@github.com