【发布时间】:2013-02-23 13:02:54
【问题描述】:
我有一个 git repo,它是另一个 repo 的一个分支。作为一项规则,我通常会添加一个名为 upstream 的远程,这是我派生出来的原始仓库。
$ git remote -v
origin git@github.com:skela/awesomeproject.git (fetch)
origin git@github.com:skela/awesomeproject.git (push)
upstream git://github.com/bob/awesomeproject.git (fetch)
upstream git://github.com/bob/awesomeproject.git (push)
有没有办法让这个额外的远程在克隆之间持久存在? 假设我删除了本地存储库并执行以下操作:
git clone git@github.com:skela/awesomeproject.git
现在我重新检查我的遥控器:
$ git remote -v
origin git@github.com:skela/awesomeproject.git (fetch)
origin git@github.com:skela/awesomeproject.git (push)
我的上游遥控器消失了!
如何确保我的 git repo 始终保留这 2 个远程别名?
编辑: 只是添加我想要这样做的主要原因,以便将一些答案塑造成可接受的路径;)
目标是在我的 repo 中有一个分支来跟踪上游的 master。
[remote "upstream"]
url = git://github.com/bob/awesomeproject.git
fetch = +refs/heads/*:refs/remotes/upstream/*
[branch "father"]
remote = upstream
merge = refs/heads/master
换句话说,我的仓库中的“父亲”分支跟踪称为上游主分支的远程分支。
一旦我设置它一切都很好,但是一旦我再次克隆回购,“父亲”分支指向原点而不是上游。
【问题讨论】:
-
Preserve git remotes的可能重复
标签: git github git-clone git-remote