简体   繁体   English

git push不会将最新提交推送到远程

[英]git push does not push latest commit to remote

git push does not push latest commit to remote. git push不会将最新提交推送到远程。

Steps to reproduce: 重现步骤:

  1. With a local project, last commit amended a few times before push. 对于本地项目,最后的提交在推送之前已修改了几次。
  2. Create a new empty project. 创建一个新的空项目。 (in gitlab) (在gitlab中)
  3. Add the new project origin. 添加新的项目原点。
  4. git push -u [origin] [branch]. git push -u [起源] [分支]。

Problem: 问题:

git keeps push outdated commit to remote! git继续将过时的提交推送到远程! Not the commits I locally amended before push. 不是在推送之前我在本地修改的提交。

How can I force git to cleanup and don't remember the stale commits? 我该如何强制git进行清理,并且不记得过时的提交?

Added Information: git 2.1.0 新增信息:git 2.1.0

git branch shows detached state git branch显示分离状态

That would explain why pushing a branch to any remote would push an "outdated" commit: the branch still refer to the old commit, while the new amended commit (referenced by HEAD) is detached from any branch. 那可以解释为什么将分支推送到任何远程都会推送“过时”的提交:分支仍然引用旧的提交,而新修改的提交(由HEAD引用)与任何分支分离。

You can force a branch to reset to the current HEAD 您可以强制分支重置为当前HEAD

git branch -f master HEAD

That would reset the branch master to the current amended commit. 这样会将分支主服务器重置为当前修订的提交。

Then you can create a new Gitlab repo, and git push -u origin master . 然后,您可以创建一个新的Gitlab存储库和git push -u origin master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM