英文:
Pushing changes to Git repository results in 'Updates were rejected' error, how to fix it?
问题
抱歉,以下是翻译好的部分:
我在一个在线代码库上,只有我能够推送提交,除了主分支外没有其他分支。最近这些天,我一直在上面工作,并成功推送了提交,包括文件夹和文件等。
但是今天,当我尝试推送更改以更新代码库中的最新文件和文件夹时,出现了以下错误:
error: failed to push some refs to 'https://github.com/repo.git'
hint: Updates were rejected because the tip of your current branch is behind
To https://github.com/repo.git
hint: its remote counterpart. Integrate the remote changes (e.g.
! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
hint: 'git pull ...') before pushing again.
Done
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
我正在使用Pycharm社区版13.2,通常通过在左侧菜单中选择“提交”部分,然后编写注释并推送提交来更新代码库,就像这里的操作一样:
我也从未在在线代码库上进行过任何更改,始终保持本地文件,然后进行推送。我已经尝试过获取和更新项目,但没有解决问题,所以在破坏我的代码库之前,我想寻求帮助。
编辑:我确实对在线代码库进行了一些更改。我添加了一个LICENSE.md文件,它显示在我的远程历史更改中。
英文:
I have an online repository on which I am the only person that can push commits, and there are no more branches than the main one. I have been working on it these days, and pushed commits without an issue, including folders and files etc.
Except today, when I try to push changes to update the repository with the latest files and folders I have, it gives me this error:
error: failed to push some refs to 'https://github.com/repo.git'
hint: Updates were rejected because the tip of your current branch is behind
To https://github.com/repo.git
hint: its remote counterpart. Integrate the remote changes (e.g.
! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
hint: 'git pull ...') before pushing again.
Done
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
I am using Pycharm Community Edition 13.2, and always update by selecting the Commit section in the left bar menu and then writing a comment and pushing the commit like in here:
I also never touched the online repository to make any changes, always kept local files which were then pushed. I already tried to fetch and to update the project but it didn't fix, so before I break my repository I want to ask for help
EDIT: I did make some changes to the online repository. I had added a LICENSE.md file which shows up in my remote history changes.
答案1
得分: 1
你说你是唯一一个推送该存储库的人,但Github告诉你你的版本落后于远程版本。
首先,我建议您检查远程历史记录,以查看是否有其他人推送了其他内容。
如果您发现有一些远程更改,您应该使用git pull -r
执行带有rebase的git pull。
英文:
You say that you are the only one who push on that repository, but Github tells you that your head is older (behind) the remote one.
Before of all, I suggest you to inspect the remote history to check if somebody (?) pushed something else.
If you will discover some remote changes you should do a git pull with a rebase by git pull -r
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论