简体   繁体   English

对于Ruby on Rails项目的请求请求,git push到我的fork失败

[英]For Ruby on Rails project pull request, git push to my fork failing

I made fixes and tests, git commit -a , updated my branches and now I'm trying to push to a GitHub fork I had previously made: 我进行了修复和测试, git commit -a ,更新了我的分支,现在我正尝试推送到我之前做过的GitHub分支:

vagrant@rails-dev-box:~/rails$ git push mine my_fix
Username for 'https://github.com': myusername
Password for 'https://myusername@github.com':
To https://github.com/myusername/rails.git
 ! [rejected]        my_fix -> my_fix (non-fast-forward)
error: failed to push some refs to 'https://github.com/myusername/rails.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.

I'm guessing the reason for this issue is the fork is a little outdated (by a week maybe). 我猜这个问题的原因是叉子有点过时了(也许一周了)。 I've made other pushes to the fork though that I don't want to lose. 尽管我不想输,但我还是做出了其他努力。 What do I do here? 我在这里做什么?

I think your branch is not up-to-date so you need to pull recent change then push your changes to remote. 我认为您的分支不是最新的,因此您需要提取最近的更改,然后再将更改推送到远程。

    $git pull --rebase branch_path
    $git push remote_name branch_name

Your (Github) fork know nothing about upstream changes 您的(Github)前叉对上游更改一无所知

Message states clearly 消息状态清楚

Merge the remote changes 合并远程更改

ie - in your Github repo you have changesets , that are not in the local repo 即-在您的Github存储库中,您有更改集 ,而这些 更改集 不在本地存储库中

While on a master branch locally: 在本地master分支上时:

  1. You need to add rails/rails as upstream: git remote add upstream git://github.com/rails/rails.git 您需要将rails / rails添加为上游: git remote add upstream git://github.com/rails/rails.git
  2. Now, pull with rebase (not with merge, as it will be easier to keep up with updates on rails/rails if you rebase) git pull --rebase upstream master 现在,使用rebase进行拉取(而不是使用合并,因为使用rebase进行更新会更容易跟上rails / rails的更新) git pull --rebase upstream master
  3. Push the changes to your master (you will need force to push, but be careful and make sure you are OK with the changes, since previous changes will be somewhat harder to recover after this operation) git push --force origin master 将更改推送到主服务器(您将需要强行推送,但是要小心并确保对更改没问题,因为在执行此操作后,以前的更改将很难恢复) git push --force origin master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM