常用 git命令

检出分支

git clone -b dev git@gogs.taskwedo.com:PM/TechSharing.git ownbranchname

查看源

git remote 
git remote -v

更改1

git remote set-url origin xxxxx

更改2

git remote rm origin 
git remote add origin xxxxxxxxx

更改3

vim .git/config

新增源

git remote add originname originurl

不新增源只增 url

git remote set-url --add origin newurl

分支关联

git push -u origin remoteBranch
git branch --set-upstream-to=origin/remoteBranch

创建分支

git branch branchname
git checkout -b branchname

合并分支

git checkout dev
git merge --no-ff mergedBranch

删除分支

git branch -d localbranch
git branch -D localbranch
git push -d origin remotebranch
git push origin :dev

查看历史

git blame filename  #查看最后是谁修改的,每一行 
git blame -L 160,+10 filename
git log [--oneline|--graphy|--all] filename
git log -p filename #查看详细历史修改,没有-p 只有提交记录,-p 后可以接数字,表明最近多少次提交历史

配置别名

git config --global alias.st status
git config --global alias.ci commit

其他命令

git stash

配置文件地址

~/.gitconfig
.git/config

设置
查看

git config --list

推送设置

git config --global push.default matching #名称匹配到的
git config --global push.default simple # 仅当前分支对应

其他统一设置

git config --global user.name '123'
git config --global user.email '123@qq.com'
git config --global core.filemode false  # 忽略文件权限
git config --global core.ignorecase false

windows 中

git config --global core.autocrlf false  # 换行符转换
git config --global gui.encoding utf-8  # 避免 ui 乱码
git config --global core.quotepath off   # 避免 git status 中文文件名乱码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值