使用Git for Windows推送到GitHub时出错 [英] Error pushing to GitHub using Git for Windows
问题描述
我在GitHub上创建了一个Git仓库,并且也创建了一个本地仓库。首先,我将远程存储库放入本地存储库。然后,我添加了一个文件,对文件进行了分阶段提交,现在我尝试再次对远程存储库进行推送,但是失败并显示以下消息:
推送到https://github.com/jjenkov/java-utils
到https://github.com/jjenkov/java-utils
! [拒绝]主 - >主(非快进)
错误:未能将一些文件推送到'https://github.com/jjenkov/java-utils'
提示:更新被拒绝因为当前分支的提示位于
提示后面:它的远程对象。合并远程更改(例如'git pull')
提示:再次按下之前。
hint:详细信息请参阅'git push --help'中的'快速转发注意'。
我完全不熟悉Git和Github,所以也许我做错了什么。我已经将远程仓库提取到本地仓库中,尽管远程仓库应该是空的(除了由GitHub生成的自述文件)。
有人知道什么是什么问题是,或者我可以在哪里阅读解决方案?
远程仓库不是空的;它包含可能通过GitHub Web界面创建的 README
。您必须在推送到它之前将它拉出来:
git pull --rebase origin master
git push
(
I have created a Git repository on GitHub, and a local repository too. First I pulled the remote repository into the local one. Then I added a file, staged the file, committed it, and now I try to do a push to the remote repository again, but it fails with this message:
Pushing to https://github.com/jjenkov/java-utils To https://github.com/jjenkov/java-utils ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/jjenkov/java-utils' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
I am completely new to Git and Github, so maybe I am doing something wrong. I have "fetched" the remote repository into the local one, although the remote repository should be empty (except for a readme file generated by GitHub).
Does anyone know what the problem is, or where I can read a solution?
The remote repo is not empty; it contains a README
that you probably created through the GitHub web interface. You have to pull it before you can push to it:
git pull --rebase origin master
git push
(The --rebase
is not strictly necessary but avoids an ugly merge commit.)
这篇关于使用Git for Windows推送到GitHub时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!