git status
之后,您应该会看到类似的内容
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
重要的部分是“ 2次提交”!从这里继续输入:
git reset HEAD~<HOWEVER MANY COMMITS YOU WERE BEHIND>
因此,对于上面的示例,将键入:
git reset HEAD~2
输入后,您的“ git状态”应显示为:
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
然后
git add .
git commit -m"注释"
git push