我已经分叉了一个 github 存储库,现在我的分叉已经进行了几次提交。我现在想提供one这些提交作为原始存储库的 PR。
下列的这个问题的答案 https://stackoverflow.com/questions/21527233/create-a-pull-request-for-a-single-commit-made-on-a-fork-of-a-fork-on-github, I did:
git remote add official [URL to original repo]
git checkout -b hotfix-for-feature official/master
git cherry-pick [feature-hash]
git push -u origin hotfix-for-feature
我得到:
! [rejected] hotfix-for-feature -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/myusername/repositoryname'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
注意如何:
- 分支参数为
git push -u
完全被忽略,它想推送到 origin/master
- Neither
origin/hotfix-for-feature
nor official/hotfix-for-feature
远程存在。
-
official/master
无论如何都不领先——我真的只是拿到了它
如果我尝试git branch hotfix-for-feature --set-upstream=origin/hotfix-for-feature
有人告诉我git push -u
是执行此操作的正确方法。如果我尝试git push -u origin/hotfix-for-feature
I get:
fatal: You are pushing to remote 'origin/hotfix-for-feature',
which is not the upstream of your current branch 'hotfix-for-feature',
without telling me what to push to update which remote branch.
这 - 除了是如何不写错误消息的一个很好的例子 - 我不明白。我指定要推送的内容(当前分支)以及要更新的远程分支。
我发现很多关于此错误的问题,但它总是与某个远程分支有关,在这种情况下,不存在现有的远程分支。另外,“推送分支”和“远程[分支]”之间有什么区别?