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

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

问题描述

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



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

  git remote添加源https://github.com/aniruddhabarapatre/learn-rails.git 

之后我进入我的用户名和密码

  git push -u origin master 

错误---

 转至https://github.com/ aniruddhabarapatre / learn-rails.git 
! [被拒绝] master - > master(获取第一个)
错误:未能将某些参考文献推送到'https://github.com/aniruddhabarapatre/learn-rails.git'
提示:更新被拒绝,因为远程包含您的工作做
提示:不在本地。这通常是由另一个存储库推动
hint:引起的。在再次推送之前,您可能需要首先合并远程更改(例如
hint:'git pull')。
提示:有关详细信息,请参阅'git push --help'中的'关于快速转发的注意事项'。

这是我第一次将我的代码推送到Github存储库,并且我迷失了这些错误。我搜索了其他几个在这里提出的问题,但他们都没有问题。

=https://github.com/aniruddhabarapatre/learn-rails =noreferrer>您在GitHub上的仓库,您创建了 README.md ,它是一个新的提交



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


更新已被拒绝,因为远程包含的工作是
不在本地。


您可能想要查看以下建议:


您可能希望在再次推送前先合并远程更改(例如,
' git pull ')。


即:

  git pull 
#修复任何合并冲突,如果你在本地有一个`README.md`
git push -u origin master


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

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

Error ---

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.

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.

解决方案

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:

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

That is:

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

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

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