当前位置:   article > 正文

git将多个commit合并成一个

git 本地代码多次comiit 合并程一个

1. 查看提交历史(最近10个)

git log -10

2. 回到前面第十个commit,且将后面九个commit提交的内容状态改为未提交

git reset commitID(第十个commit的ID)

3. 提交修改的内容

git add .
git commit -m "dev: 将前九个commit合并为一个"

4. 提交到远程分支

$ git push origin change_skin
To git@192.168.0.116:rubik-x/rubik-project.git
 ! [rejected]        change_skin -> change_skin (non-fast-forward)
error: failed to push some refs to 'git@192.168.0.116:rubik-x/rubik-project.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

5. 执行报错,由于本地没有远程的前九个commit节点,且想将自己的新的commit节点提交,如下所示:

6. 如果该分支上的代码仅你一个人在更新,可以强制执行本地代码覆盖远程代码操作(远程的前9个commit将删除,本地的合并后的commit将推到远程):

git push -f origin change_skin

 

转载于:https://www.cnblogs.com/miaoying/p/9214028.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/399482
推荐阅读
相关标签
  

闽ICP备14008679号