git 提交错分支如何处理

场景:代码已经commit ,发现提错了分支
步骤:

  1.git reset HEAD^     //把上次提交恢复为未提交状态
  2.git status   //查看当前状态
  3.git  stash    //将修改add到暂存区,暂存代码
  4.git checkout 分支  //切换到需要提交的分支
  5.git stash pop   //恢复成功,可提交

  然后就可以安装提交步骤提交代码了
  6. git pull     //先更新再提交
  7. git status    //查看当前状态
  8. git add .   //添加到暂存区
  9. git commit -m '提交注释'
  10. git pull     //提交到远程

猜你喜欢

转载自www.cnblogs.com/Kyaya/p/12568618.html
今日推荐