一次性commit好多文件,push上去以后,发现工程不可用,只能回滚,上网搜索回滚办法,下边这个是本身亲试的,特别好使:git
操做步骤:web
一、git checkout the_branch3d
二、git pullblog
三、git branch the_branch_backup //备份一下这个分支当前的状况it
四、git reset --hard the_commit_id //把the_branch本地回滚到the_commit_id搜索
五、git push origin :the_branch //删除远程 the_branchim
若是the_branch是默认分支的话,会提示默认分支不可删除,此时能够去web git上修改默认分支为其余分支,img
,若是没有其余分支了,那就新建一个tmp分支,使其成为默认分之便可di
六、git push origin the_branch //用回滚后的本地分支从新创建远程分支文件
七、git push origin :the_branch_backup //若是前面都成功了,删除这个备份分支
因为前边只备份到本地了,没有push到远程分支上,因此如今删除远程分支时会提示没有这个branch
做者:飞将军连接:https://www.jianshu.com/p/0b50e4a43cdf來源:简书简书著做权归做者全部,任何形式的转载都请联系做者得到受权并注明出处。