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

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

问题描述

我创建了一个新的存储库,克隆它,将文件添加到目录中,使用 add -A 添加它们,提交更改,以及当我尝试使用 git push <repo 推送时姓名>大师我得到:

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天全站免登陆