【问题标题】:failed to push some refs未能推送一些裁判
【发布时间】:2012-07-24 08:44:13
【问题描述】:

我正在尝试推送到 github 我按照以下步骤操作: (在这些行之前我位于我的应用程序目录中)

$ mkdir estaciones
$ cd estaciones
$ git init
>>Initialized empty Git repository in /Users/armandodejesussantoyareales/Documents/project_newbie/Estaciones/estaciones/.git/
$ touch README
$ git add README
$ git commit -m "phase 3 estaciones"
>>[master (root-commit) 4462be3] phase 3 estaciones
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100755 README

(我不知道那条消息是不是错误)

$ git remote add origin git@github.com:asantoya/estaciones.git
$ git push -u origin master

但我总是遇到同样的问题,我打字晚了,我得到了下一个错误

To git@github.com:asantoya/estaciones.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:asantoya/estaciones.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

【问题讨论】:

    标签: ruby-on-rails github push


    【解决方案1】:

    这意味着远程存储库已经有一个主分支,并且它在该分支中包含自从您提交到本地副本以来已添加的内容。这是指https://github.com/asantoya/estaciones可见的代码

    首先从 github 克隆 repo,然后将更改添加到其中,然后推送:

    git clone https://github.com/asantoya/estaciones.git
    git checkout -b nameofyourbranch master
    

    添加一些文件等

    git commit -a -m "Your commit message"
    git push origin nameofyourbranch
    

    【讨论】:

    • 如果要添加所有文件,命令是:“git add .”对吗?
    • 如何替换github.com/asantoya/estaciones的现有文件和目录
    • 是的,'git add 。'将添加所有这些。如果您想擦除 github 文件并重新开始,您可以删除,然后重新创建该存储库,但您会丢失历史记录。否则,在克隆 repo 后(通过使用 git rm)在本地删除所有文件,然后添加所需的文件,提交并推送。
    猜你喜欢
    • 1970-01-01
    • 2019-06-24
    • 2014-06-26
    • 2021-08-07
    • 2021-03-26
    • 2017-12-07
    • 1970-01-01
    • 1970-01-01
    • 2020-02-18
    相关资源
    最近更新 更多