GIT不推送提交到远程 [英] GIT push not pushing commits to remote

查看:402
本文介绍了GIT不推送提交到远程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究git仓库,并且一直推动我的本地更改到远程服务器......直到最近。当我做git push时,它说所有内容都是最新的。实际上,我已经提前3次提交远程版本,并没有得到我的更改。



我试过了git log -1,git reset --hard解决方案发布在各个地方,但这并不能解决任何问题。我是否需要更改该数字以反映我未来提交的数量?



假设我有5个提交,为了brevetys的缘故命名为1到5.我的本地版本是在5,远程版本是2. Gitk显示我的MASTER在提交5和遥控/起源/主提交2.我是否需要将我的本地版本重置为2(或3,第一次提交没有推到远程)?我的更改会发生什么? git文档说 - hard将放弃任何更改,这是否意味着它们会完全丢失?我想保留这3个提交的提交历史记录,因为这里有一些改变。

首先小心谨慎检查你的配置。


  1. 确保你确实推送了它。

  2. 确保您已将其推送到您认为推送的位置。

什么可以帮助您:

  $ git log --full-history //是你的提交吗? 
$ git reflog //操作历史记录
$ git remote -v //您的遥控器是什么?
$ git remote显示DESIRED_REPO //您是否有想要推送配置的远程回购? DESIRED_REPO?

最后,请确保您使用的是正确推式表示法:


  1. git push public git push --repo = public 。首先推送到公共ALWAYS,第二只有当 没有设置

  2. 如果您的分支命名不同

$ git push remote local_branch:remote_branch // I今天通过交换位置发生了这个错误,使用remote_branch:local_branch Git不会找到要更新的分支。



希望这有帮助。在我的情况下仔细重新阅读手册,同时重新检查命令我试过帮助和揭示了问题(交换分支名称)。


I have been working on a git repository and have been pushing my local changes to a remote server all the time... up until recently. When I do a git push, it says that everything is up-to-date. In reality, I'm already 3 commits ahead of the remote version and it's not getting my changes.

I have tried the git log -1, git reset --hard solution posted on various places, but that doesn't solve anything. Do I need to change that number to reflect the number of commits that I am ahead?

Say I have 5 commits, for brevetys sake named 1 to 5. My local version is at 5, the remote version is at 2. Gitk shows my MASTER at commit 5 and remotes/origin/master at commit 2. Do I need to git reset my local version to 2 (or 3, the first commit that was not pushed to remote)? What will happen to my changes? The git documentation says that --hard will discard any changes, will that mean that they will be lost completely? I would like to keep the commit history of these 3 commits, as there were quite some changes made.

解决方案

First of all carefully examine your configuration.

  1. Make sure you have pushed it really.
  2. Make sure you have pushed it to where you THINK you pushed it.

What can help you:

$ git log --full-history // is your commit really there?
$ git reflog // operation history
$ git remote -v // what are your remotes? 
$ git remote show DESIRED_REPO // do you have the remote repo you wanted to push to configured? the DESIRED_REPO?

Finally, make sure you are using RIGHT push notation:

  1. There is a difference between git push public and git push --repo=public. First pushes to public ALWAYS, second only if remote for branch you are pushing is not set.
  2. If your branch is named differently than it's remote counterpart, this can make a difference.

$ git push remote local_branch:remote_branch // I've made this error today by swapping places, with remote_branch:local_branch Git will not find the branch to update.

Hope this helps. In my case careful re-reading of manual while re-examining commands I've tried helped and revealed the problem (swapped branch names).

这篇关于GIT不推送提交到远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆