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