Git使用中常用命令

1、创建分支: git branch <branch-name>
2、查看本地所有分支:git branch -a
3、切换分支:git checkout <branch-name>
4、合并代码到当前分支:git merge <branch-name>
5、新建tag: git tag -a <tag-name> -m "注释"
6、查看所有tags:git tag
7、查看tag详情:git show <tag-name>
8、版本回退:git reset --hard <commitId>
9、查看所有提交日志:git reflog
10、推送所有tags到远程:git push origin --tags
11、将uncommit代码贮藏(临时保存):git stash save "stash-name"
12、查看所有stash代码:git stash list
13、应用stash代码(apply last stash and remove it from the list):git stash pop
14、应用stashd代码(apply stash with stash@{n}):git stash apply stash@{1}
15、清空临时贮藏列表:git stash clear
16、修改项目远程仓库地址:git remote set-url origin newAddr ,进入.git/下查看 config信息是否变更;

17、强推到远程master分支:git push origin branchName --force

通过tag修复bug流程:
1、查看项目所有tag
1)git tag
2、查询tag详情找到commitId
1)git show <tag-name>
3、主分支回退到打标签的那次提交   
1)git reset --hard <commitId>
4、拉取分支  
1)bugfix git checkout -b <branch-name>
5、主分支立即回到最新状态  
1)git checkout master  
2)git reflog
3)git reset --hard <commitId>  (回到最新版本)
6、切换到bugfix分支,修改bug,发版本,打新标签  
1)git checkout <branch-name>
7、合并bugfix分支到主干上 
1)git checkout master
2)git merge <branch-name>
3)git push origin master
8、手动推送标签到远程
1)git push origin --tags

















 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值