Github“更新被拒绝,因为远程包含您在本地没有的工作." [英] Github "Updates were rejected because the remote contains work that you do not have locally."

查看:108
本文介绍了Github“更新被拒绝,因为远程包含您在本地没有的工作."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的存储库,将其克隆,将文件添加到目录中,并用add -A添加了它们,提交了更改,当我尝试使用git push <repo name> master进行推送时,我得到了:

I created a new repo, cloned it, added files to the directory, added them with add -A, committed changes, and when I try to push using git push <repo name> master I get:

提示:更新被拒绝,因为远程包含您在本地没有的工作.这通常是由另一个存储库推送到相同的引用引起的.您可能需要先合并远程更改(例如, 提示:"git pull"),然后再次按下.

hint: Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first merge the remote changes (e.g., hint: 'git pull') before pushing again.

这似乎没有任何意义,因为它是一个新的回购协议,并且仅包含一个自述文件.

This doesn't seem to make sense since it's a new repo and contains only a readme file.

推荐答案

如果您使用README和/或LICENSE文件初始化了新的github存储库,则会发生这种情况

This happens if you initialized a new github repo with README and/or LICENSE file

git remote add origin [//your github url]

//pull those changes

git pull origin master 

// or optionally, 'git pull origin master --allow-unrelated-histories' if you have initialized repo in github and also committed locally

//now, push your work to your new repo

git push origin master

现在您将能够将您的存储库推送到github.基本上,您必须将这些新的初始化文件与您的工作合并. git pull为您获取并合并.您也可以根据需要获取并合并.

Now you will be able to push your repository to github. Basically, you have to merge those new initialized files with your work. git pull fetches and merges for you. You can also fetch and merge if that suits you.

这篇关于Github“更新被拒绝,因为远程包含您在本地没有的工作."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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