我将从一些详细的背景信息开始:
通常在我们的讲座中,我们将我们的教师 repo git clone 到其中一个学校服务器中。 然后,我们对文件进行更改、提交并从 PuTTy 推送它们。
对于我们的家庭作业,我们 fork 教师存储库,git 将它们克隆到服务器中,同样的事情再次发生。
这让我想到了我的具体问题:也就是说,因为它已经被克隆了,所以我认为没有必要再次复制文件,所以我继续我的更改,git add ., git commit -m "comment"但是当它来将更改推送到 Github,它 pop 一个错误。这真的很奇怪,因为我已经将我的提交推送到我的 fork 存储库中,但这次由于某种原因它似乎不起作用。
错误信息:
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 pull origin your_branch
或(以上命令等于以下两个步骤):
git fetch origin your_branch
git merge your_branch
关于git - 如何将您的更改推送到 Github 上的 fork repo ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40307770/