Git一些麻煩使用示例
阿新 • • 發佈:2020-08-26
設定賬號和使用者名稱
# 檢視git config設定
git config -l
git config --global user.name "xxx"
git config --global user.email "xxx"
Github / Gitee新增金鑰
# 生成金鑰
ssh-keygen -t rsa
# 檢視公鑰
cat ~/.ssh/id_rsa.pub
將公鑰新增到Github / Gitee
新增多個遠端倉庫
1. 將主庫git到本地
# 新增gitee庫,使用ssh連結以防git push總是需要密碼 git remote add <遠端庫名> <ssh> # 檢視遠端倉庫地址 git remote -v
2. push
git push && git push <遠端庫名>
3. 副庫出現衝突
hint: Updates were rej ected because the tip of your current branch is behind
4. 強行推送到副庫
# git push -u <遠端庫名> <版本名> -f
git push -u gitee master -f
加速Git
1. 安裝nslookup
sudo yum install bind-utils
2. 查詢DNS
nslookup github.com nslookup github.global.ssl.fastly.net
3. 修改hosts
4. 重新整理快取
-
ubuntu
sudo /etc/init.d/networking restart
-
mac
sudo dscacheutil -flushcache
-
windows
ipconfig /flushdns
拉取專案,修改程式碼後建立新版本
1. 拉取已經fork遠端專案
git clone 遠端專案
2. 修改專案檔案
3. 建立版本分支
git branch test
4. 切換到版本分支
git checkout test
5. 提交檔案
git commit -m "test"
6. 同步到遠端分支版本
git push origin test