【问题标题】:How to push your changes into a forked repo on Github?如何将您的更改推送到 Github 上的分叉存储库中?
【发布时间】:2016-10-28 14:55:31
【问题描述】:

我将从一些详细的背景信息开始:​​

通常,对于我们的讲座,我们会将老师的代码库克隆到其中一台学校服务器中。 然后我们对文件进行更改,提交它们并从 PuTTy 推送它们。

对于我们的家庭作业,我们 fork 教师存储库,将它们 git clone 到服务器中,同样的事情再次发生。

这让我想到了我的具体问题:也就是说,因为它已经被克隆了,所以我认为不需要再次复制文件,所以我继续我的更改, git add ., git commit -m "comment" 但是当它来到将更改推送到 Github 时,它会弹出一个错误。这真的很奇怪,因为我已经将我的提交推送到我的分叉存储库中,但这次它似乎由于某种原因不起作用。

错误信息:

To https://my_account@github.com/my_account/homework.git
 ! [rejected]        master -> master (non-fast-forward)

error: failed to push some refs to 'https://my_account@github.com/my_account/homework.git'

To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  

See the 'Note about
fast-forwards' section of 'git push --help' for details.

我是 git 的初学者,所以如果这是一个愚蠢或不清楚的问题,我提前道歉。

【问题讨论】:

  • 先试试拉?
  • 你是从你的分叉仓库还是从老师的仓库克隆的?
  • 自己的复制品。 @巴鲁克
  • git fetch -a origin 然后 git merge branch_name 正如 Do Nhu Vy 在回答中所说的那样

标签: git github push


【解决方案1】:

你应该这样做:

git pull origin your_branch

或者(上面的命令等于下面的两个步骤):

git fetch origin your_branch
git merge your_branch

【讨论】:

    猜你喜欢
    • 2022-01-17
    • 2013-04-18
    • 1970-01-01
    • 2016-03-20
    • 2012-08-25
    • 1970-01-01
    • 1970-01-01
    • 2012-09-24
    • 2016-02-21
    相关资源
    最近更新 更多