git常用命令总结

init config

$ git config  --global user.name lazycece
$ git config  --global user.email lazycece@gmail.com
$ git config  --global color.ui auto 
$ git config  --global color.status auto 
$ git config  --global color.branch auto 
$ git config  --global color.diff auto 

仓库相关

# 添加远程仓库
git remote add remote-branch-name remote-repository
# 查看本地仓库对应的远程仓库
git remote -v
# 本地分支与远程分支对应关系
git branch -vv

分支操作

# 本地仓库当前分支push到远程
git push --set-upstream origin new-branch-name
# 创建本地分支
git branch new-branch-name
# 删除目标分支
git branch -D master
# 删除远程分支
git push origin --delete branch-name
# 切换分支
git checkout branch-name
# 创建本地分支并切换
git checkout -b new-branch-name
# 创建本地分支同时关联远程分支
git checkout -b new-branch-name origin/origin-branch-name
# 清除缓存中已删除的分支
git fetch -p

stash 操作

# 暂存当前修改
git stash
# 列出所有暂存
git stash list
# 取出最新的暂存
git statsh pop
# 取出指定暂存
git stash pop stash@{0}
# 清楚所有暂存
git stash clear
# 删除暂存
git stash drop 

merge 操作

git merge --no-ff branch-name
git fetch origin master
git diff local-branch oringin/master
git merge origin/master
git rebase origin/master
git reset merge

tag 操作

# 列出所有tag
git tag
# 为当前分支最新commit上打tag
git tag tag-name
# 创建带有说明的标签,用-a指定标签名,-m指定说明文字
git tag -a tag-name -m "message"
# 列出commit-id
git log --pretty=oneline --abbrev-commit
# 在某一个commit上打tag
git tag tag-name commit-id
# 查看tag信息
git show tag-name
# 推送tag到远程
git push origin tag-name
# 一次性推送所有tag到远程
git push --tags
# 删除本地标签
git tag -d tag-name
# 删除远程tag
git push origin :refs/tags/tag-name
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值