如何将在分叉回购上创建的分支添加到上游回购?

How to add a branch, created on a forked repo, to the upstream repo?

我正在将我的修补程序分支从 Mercurial 迁移到 Git。我使用 hg-git 插件将我的修补程序分支导入到我的 git 项目的分叉回购上的新分支。有没有办法将新创建的分支添加到上游仓库?该分支当前不存在于上游仓库中。

我试过运行...

git push u git@git.<name of upstream repo>.git hotfix

但是出现错误....

error: src refspec git@git.<name of upstream repo> does not match any
error: failed to push some refs to 'u'

您应该使用 -u 而不是 u。你可以试试这个命令:git push -u origin hotfix

注意: origin 是 remote 的默认短名称。您可以使用 git remote -v 来检查您的远程短名称是 origin 还是 else。