美文网首页
git 常用命令

git 常用命令

作者: 放手緣分 | 来源:发表于2020-04-03 15:19 被阅读0次

登录

git config --global user.email 'xianhe_yan@sina.com'

git config --global user.name 'yanxianhe' 

设置http postBuffer 500M / 2G

  • 500M

git config http.postBuffer 524288000

  • 2G

git config http.postBuffer 17179869184

将本地初始化项目提交到 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

设置代理全局

# 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

针对单个程序

> 进入目录下执行

git config http.proxy 'socks5://127.0.0.1:20800'
git config https.proxy 'socks5://127.0.0.1:20800'
创建分支
git branch yxh_2019

查看分支
git branch -r

添加跟踪
git branch --set-upstream-to=origin/488-20190619
创建分支并切换分支
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 分支合并到本地
合并两个分支修改同一个文件时(远程分支与本地同时修改一个文件)

a. git pull #会提示有error 文件 

b. git add file # 将修改文件先添加到当前分支

c.  git commit   # 重新提交文件

d. git stash    # 保存分子

e. git pull     # 提示自动合并文件

f. 找到冲突文件,逐个解决

g. git add file # 将解决后的冲突文件添加

h. git commit   # 重新提交文件

hi. git push     # 提交分支

j. git push origin --delete # 删除远程分支

git stash list //查看暂存区的所有暂存修改
git stash apply stash@{X} //取出相应的暂存
git stash drop stash@{X}  //将记录列表中取出的对应暂存记录删除

查看远程仓库
git remote -v
查看远程仓库
git remote -v
强制更新本地分子
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 设置编码
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 设置编辑器

git config --global core.editor vim

git 回退分支[受保护分支需要去掉保护后提交]

-- 查看当前版本

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

相关文章

网友评论

      本文标题:git 常用命令

      本文链接:https://www.haomeiwen.com/subject/bqnhphtx.html