Git在修改提交后阻止推送
通常,我只是跑步
git add file
git commit
git push
  但如果我在推送之前修改提交(使用git commit --amend ),则下一次推送将失败 
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.
  我怎样才能让git在不合并分支的情况下推送更改?  我只有一个分支( master ),我是唯一使用这个回购的人,所以为什么这么说? 
git分支-a:
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  编辑:使用gitk HEAD @{u} ,我看到我有2个分支,一个是原始提交,另一个是修改后的提交。 
  只有当您正在修改已推送的提交时,才会出现这种情况。  一般来说,你不应该那样做,因为你正在修改已发布的历史。  但是,对于您的情况,您应该能够通过push -f离开,这将使用您的修订版本覆盖远程提交。 
是的,你不应该这样做(推动一个提交,然后改变它并试图再推一次)。
相反,您可以在不更改文件的情况下将Git回滚到之前的提交,然后创建一个新的提交:
git reset --mixed origin/master
git add .
git commit -m "This is a new commit for what I originally planned to be an amendmend"
git push origin master
这将对您将要修改的更改进行新的提交。
你修改了拉取的提交
git pull origin master
git commit -a --amend -m "..."
git push
您可以通过恢复修改的提交来解决该问题:
git reset --mixed origin/master
然后再作为一个完整的承诺
链接地址: http://www.djcxy.com/p/48931.html