git 无法推送到 github:一切都是最新的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11084515/
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
cannot push to github: everything up-to-date
提问by Kricket
On github, I forked an old version of another project. I made some changes and am trying to push them onto my fork on github. I commited the changes locally, then tried git push, but this simply tells me "Everything up-to-date". When I browse the project on github, however, nothing has changed: it still shows the files (from the latest version) on my fork, unmodified. How can I push the changes to my github account?
在 github 上,我 fork 了另一个项目的旧版本。我做了一些更改,并试图将它们推送到我在 github 上的分支上。我在本地提交了更改,然后尝试了 git push,但这只是告诉我“一切都是最新的”。然而,当我在 github 上浏览项目时,没有任何变化:它仍然显示我的叉子上的文件(来自最新版本),未经修改。如何将更改推送到我的 github 帐户?
(I realize this isn't much information...what else can I say? I have a feeling that it may be because I'm modifying the files directly in (home)/git/(project)...?)
(我意识到这不是很多信息......我还能说什么?我有一种感觉,这可能是因为我直接在 (home)/git/(project)... 中修改了文件?)
采纳答案by VonC
git branch -v indicates that my commit was on (no branch). As for the add, I initially commited the changes through Eclipse (with the git plugin)...when I do git add from the command line, it doesn't seem to do anything
git branch -v 表示我的提交已经开启(没有分支)。至于添加,我最初通过 Eclipse(使用 git 插件)提交了更改......当我从命令行执行 git add 时,它似乎没有做任何事情
That means you are in a DETACHED HEADmode.
You can add and commit, but from the upstream repo point of view (ie from the GitHub repo), no new commits are ready to be pushed.
You have various ways to include your local (detached HEAD
) commit back into a branch, which you will be able to push then.
See:
这意味着您处于DETACHED HEAD模式。
您可以添加和提交,但从上游存储库的角度来看(即来自 GitHub 存储库),没有准备好推送新的提交。
您有多种方法可以将本地(分离的HEAD
)提交包含回分支,然后您就可以推送该分支。
看:
- "Not currently on any branch +
git commit
+ checkout when not in any branch. Did I loose my changes?" - "detached
HEAD
explained". - "Git: How can I reconcile detached
HEAD
with master/origin?" - "Git Lesson: Be mindful of a detached head"
- "Git Tip of the Week: Detached Heads"
- “当前不在任何分支 +
git commit
+ 不在任何分支时结帐。我是否丢失了更改?” - 《超脱
HEAD
解释》。 - “ Git:我如何调和
HEAD
master/origin分离?” - “ Git 课程:注意分离的头”
- “本周 Git 提示:分离的头”
The OP mentions this article in order to fix the situation:
"git: what to do if you commit to no branch"
OP 提到这篇文章是为了解决这个问题:
“ git:如果你没有提交分支怎么办”
all we need to do is checkout the branch we should have been on and merge in that commit SHA:
我们需要做的就是检查我们应该所在的分支并在该提交 SHA 中合并:
Note that instead of merging the SHA1 that you would have somehow copied, you can memorize it with a script, using head=$(git rev-parse HEAD)
:
See "git: reliably switching to a detached HEAD and then restore HEAD later, all from a script".
Then you can merge that detached HEAD
back to the right branch.
请注意,不是合并您以某种方式复制的 SHA1,您可以使用脚本记住它,使用head=$(git rev-parse HEAD)
:
请参阅“ git:可靠地切换到分离的 HEAD,然后稍后恢复 HEAD,全部来自脚本”。
然后您可以将分离的合并HEAD
回正确的分支。
回答by Themroc
After you change files, you need to
更改文件后,您需要
git add
them prior to
他们之前
git commit
.
.
回答by Tinmarino
git commit
Will show you what files are on your local machine, uncomment what you want to upload and
将显示您本地计算机上的文件,取消注释您要上传的内容和
git push origin master
Because git add *
did not work for me (even if it didn't returned errors).
因为git add *
对我不起作用(即使它没有返回错误)。
回答by Evan Green
Not sure why people are down voting the guy with the correct answer. For me adding my email and name did resolve the issue. Although the commands are not correct.
不知道为什么人们会拒绝投票给正确答案的人。对我来说,添加我的电子邮件和姓名确实解决了问题。虽然命令不正确。
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
回答by Ganesh Bonangi
In recent git version have to configer user details git config -g user.name "name"
在最近的 git 版本中必须配置用户详细信息 git config -g user.name "name"
git config -g user.email "[email protected]"
This resolved my problem
这解决了我的问题