Git 推送不会失败但不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25246589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git push doesn't fail but doesn't work
提问by RVA
I'm using Git and I'm in front of a several problem: I can push, my coworkers can pull it, and the opposite. But the version which is on the remote is not up-to-date: if I write a TEST in the html, nobody could see it except on the local version... I thought it could come from the branch which is on the remote... isn't it ?
我正在使用 Git,但遇到了几个问题:我可以推,我的同事可以拉,反之亦然。但是遥控器上的版本不是最新的:如果我在 html 中写一个 TEST,除了本地版本之外没有人可以看到它......我认为它可能来自遥控器上的分支……不是吗?
EDIT 1 : I'll try to be more specific: I've a private repo which is on a private server. This server is used to host the website. When i commit -> pull -> push everything works great. When my coworker do the same, it's fine. On our local version, all the changes appear like my "TEST" test. But on the server, nothing is up to date. Is it the wrong branch, on the server or something?
编辑 1:我会尝试更具体:我有一个位于私人服务器上的私人回购。该服务器用于托管网站。当我提交 -> 拉 -> 推时,一切都很好。当我的同事做同样的事情时,这很好。在我们的本地版本中,所有更改都类似于我的“TEST”测试。但是在服务器上,没有什么是最新的。它是错误的分支,在服务器上还是什么?
PS : Sorry for my english, it's not my native language.
PS:对不起,我的英语不是我的母语。
采纳答案by inquiring minds
If you are doing a plain 'git push' you may need to do 'git push origin branchname' instead. Provided the file is committed, of course.
如果你正在做一个简单的“git push”,你可能需要做“git push origin branchname”。当然,前提是文件已提交。
UPDATE: Check your .git/config file. You should have an origin specified and your branch should refer to origin. Maybe there is a mismatch.
更新:检查您的 .git/config 文件。您应该指定一个原点,并且您的分支应该引用原点。也许存在不匹配。
[remote "origin"]
url = [your github repo]
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "yourbranch"]
remote = origin
merge = refs/heads/yourbranch
回答by Willem Van Onsem
The question is quite unclear, but several things can go wrong.
这个问题很不清楚,但有几件事可能会出错。
You need to
git commit
changes first. Otherwise your changes are simply not stored (unknown togit
).You've committed on a special branch. In that case the commits are actually stored on the server, but not shown by default. Other users can the checkout the branch by performing
git checkout <branch>
detecting on which branch you are yourself can be done with
git branch
You and your workers use different remote servers. You can check this by running
git remote
to generate a list of installed remotes
...
你需要先
git commit
改变。否则,您的更改不会被存储(未知git
)。你已经在一个特殊的分支上做了承诺。在这种情况下,提交实际上存储在服务器上,但默认情况下不显示。其他用户可以通过执行结帐分支
git checkout <branch>
检测你自己在哪个分支上可以完成
git branch
您和您的员工使用不同的远程服务器。您可以通过运行来检查这一点
git remote
生成已安装遥控器的列表
...
回答by Fxyang
I had the same problem which looks really similar to what Vautrinr had. I also committed and had the same response to some of the things suggested in the previous answers.
我遇到了同样的问题,看起来与 Vautrinr 的问题非常相似。我也对之前答案中建议的一些事情做出了承诺并做出了相同的回应。
The final solution to my problem comes from this awesome answer. It turns out that my HEAD was detached and all the commits I did didn't go into the master branch. When trying to push to remote server, git failed to find any difference between the two master branches and thus "Everything up to date." After fixing the detached HEAD problem, I was finally able to push my changes.
我的问题的最终解决方案来自这个很棒的答案。事实证明,我的 HEAD 被分离了,我所做的所有提交都没有进入主分支。当尝试推送到远程服务器时,git 未能找到两个主分支之间的任何差异,因此“一切都是最新的”。修复了分离的 HEAD 问题后,我终于能够推送我的更改了。
Hope this help.
希望这有帮助。