我克隆了第三方Github仓库,做了我自己的更改并推送到我自己的遥控器,我需要在不同的位置使用,创建我自己的裸机远程存储库并推送我的更改 - 基本上就像这样:
git init --bare ~/repos/customized.git
git remote add customized myname@host:/home/myname/repos/customized.git
git push --all customized
git remote rename origin upstream
执行git branch -a
会产生此输出:
$ git branch -a
* master
remotes/rca_customized/master
remotes/upstream/HEAD -> upstream/master
remotes/upstream/master
我现在想要的是让主分支引用我的customized
仓库,以便git push
自动推送到customized
我怀疑应该导致git branch -a
生产下面的输出。
$ git branch -a
* master
remotes/upstream/master
remotes/customized/HEAD -> customized/master
remotes/customized/master
我不确定的是,在完成我想要的本地回购并推送到自定义'后,从其他位置克隆customized
将导致{{1}的输出显示git branch -a
在初始位置显示origin
的位置。我更倾向于说customized
而不是customized
,但可能有充分理由坚持原始惯例。
答案 0 :(得分:1)
您可以使用--set-upstream-to
更改本地分支的跟踪远程分支。
$ git checkout master
$ git branch --set-upstream-to customized/master
在the docs中获取有关远程分支的更多信息。
origin
只是git分配给您克隆的存储库的默认远程名称。远程名称只是URL的别名,并且是每个存储库的本地名称。因此,您根本无法设置远程来指示其克隆为远程引用设置除origin
之外的特定名称。如果要使用其他名称,则必须在克隆后手动重命名。