在 Github 中推送新代码的问题 [英] Issue pushing new code in Github

查看:27
本文介绍了在 Github 中推送新代码的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Github 上创建了一个新的存储库,现在只有 Readme.md 文件.

I created a new repository on Github which has only Readme.md file now.

我有一个新创建的 RoR 项目,我想将其推送到此存储库.以下是我在终端中执行的命令以及我遇到的错误.

I have a newly created RoR project which I wanted to push to this repository. Following are the commands I gave in my Terminal to execute this along with the error I am getting.

git remote add origin https://github.com/aniruddhabarapatre/learn-rails.git

之后我输入了我的用户名和密码

After which I entered my username and password

git push -u origin master

错误---

To https://github.com/aniruddhabarapatre/learn-rails.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/aniruddhabarapatre/learn-rails.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

这是我第一次将我的代码推送到 Github 存储库,但我对错误感到迷茫.我在此处搜索了一些其他问题,但没有一个是第一次遇到问题.

This is my first time pushing my code to a Github repository and I'm lost with the errors. I searched few other questions that are asked here, but none of them had issues first time.

推荐答案

当您在 GitHub 上创建您的存储库时,您创建了一个 README.md,它是新提交.

When you created your repository on GitHub, you created a README.md, which is a new commit.

您的本地存储库还不知道此提交.因此:

Your local repository doesn't know about this commit yet. Hence:

更新被拒绝,因为遥控器包含您所做的工作本地没有.

Updates were rejected because the remote contains work that you do not have locally.

您可能希望遵循以下建议:

You may want to find to follow this advice:

您可能想先合并远程更改(例如,'git pull') 然后再推送.

You may want to first merge the remote changes (e.g., 'git pull') before pushing again.

即:

git pull
# Fix any merge conflicts, if you have a `README.md` locally
git push -u origin master

这篇关于在 Github 中推送新代码的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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