登錄
git config --global user.email 'xianhe_yan@sina.com'
git config --global user.name 'yanxianhe'
設(shè)置http postBuffer 500M / 2G
git config http.postBuffer 524288000
git config http.postBuffer 17179869184
將本地初始化項(xiàng)目提交到 gitlib
- gitlib http://10.112.129.116/
-
git init
git remote add origin http://10.112.129.116/yanxianhe/cms.git
添加忽略文件不生效
git rm -r --cached .
git add .
git commit -m "update getigenore"
git push
設(shè)置代理全局
# git clone http://...
git config --global http.proxy 'socks5://127.0.0.1:20800'
# git clone https://...
git config --global https.proxy 'socks5://127.0.0.1:20800'
# git clone git://...
git config --global core.gitproxy 'socks5://127.0.0.1:20800'
# clok git proxy
git config --global --get http.proxy
取消 proxy
git config --global --unset core.gitproxy
git config --global --unset http.proxy
git config --global --unset https.proxy
針對(duì)單個(gè)程序
> 進(jìn)入目錄下執(zhí)行
git config http.proxy 'socks5://127.0.0.1:20800'
git config https.proxy 'socks5://127.0.0.1:20800'
創(chuàng)建分支
git branch yxh_2019
查看分支
git branch -r
添加跟蹤
git branch --set-upstream-to=origin/488-20190619
創(chuàng)建分支并切換分支
git checkout -b yxh_2019_1
git checkout -b 265-yanxianhe origin/265-yanxianhe
刪除分支
git branch -d yxh_2019
合并本地分之
git merge yxh_2019_1 yxh_2019_2
或 git merge yxh -- 將yxh 分支合并到本地
合并兩個(gè)分支修改同一個(gè)文件時(shí)(遠(yuǎn)程分支與本地同時(shí)修改一個(gè)文件)
a. git pull #會(huì)提示有error 文件
b. git add file # 將修改文件先添加到當(dāng)前分支
c. git commit # 重新提交文件
d. git stash # 保存分子
e. git pull # 提示自動(dòng)合并文件
f. 找到?jīng)_突文件,逐個(gè)解決
g. git add file # 將解決后的沖突文件添加
h. git commit # 重新提交文件
hi. git push # 提交分支
j. git push origin --delete # 刪除遠(yuǎn)程分支
git stash list //查看暫存區(qū)的所有暫存修改
git stash apply stash@{X} //取出相應(yīng)的暫存
git stash drop stash@{X} //將記錄列表中取出的對(duì)應(yīng)暫存記錄刪除
查看遠(yuǎn)程倉庫
git remote -v
查看遠(yuǎn)程倉庫
git remote -v
強(qiáng)制更新本地分子
git fetch --all
git reset --hard origin/master
git pull
# git pull git@ip:audit/designdoc.git yxh_201903011428
# git fetch --all && git reset --hard origin/master && git pull
保存記錄密碼
git config credential.helper store
# git config --global credential.helper store
git 設(shè)置編碼
git config --global i18n.commitencoding utf-8
git config --global i18n.logoutputencoding utf-8
--
git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.logoutputencoding utf-8
--
git 設(shè)置編輯器
git config --global core.editor vim
git 回退分支[受保護(hù)分支需要去掉保護(hù)后提交]
-- 查看當(dāng)前版本
git rev-parse HEAD
-- 查看日志
git log -10 或 git log --pretty=oneline
-- 回退指定版本
git reset --hard
-- git reset --hard cc35cf7eaca7bf224589298bf1147a4e8968166c
-- 查看版本
git rev-parse HEAD
git push -f