使用 base/trunk 作为上游标签从 public 存储库创建私有分支
Creating a private fork from a public repository with base/trunk being an upstream tag
存储库设置
分叉一个私有存储库
克隆 public 回购到私人回购
git clone --bare git@github.com:`upstream`/`upstream-repo`.git
cd `upstream-repo`.git
git push --mirror git@github.com:`origin`/`origin-repo`.git
创建工作目录
git clone git@github.com:`origin`/`origin-repo`.git
git remote add upstream git@github.com:`upstream`/`upstream-repo`
git fetch upstream
删除除 master 和 legacy 之外的所有分支(为清楚起见)
git push origin --delete `all branches excpt. master and legacy`
设置远程跟踪分支
git branch --set-upstream-to upstream/master master
git branch --set-upstream-to upstream/legacy legacy
让主干分支成为来自上游的标签
There is no such thing as a "remote Git tag"
发件人:
所以标签是本地标签,可以用git fetch upstream --tags
更新
从本地标签创建原始中继(名为 origin-repo
)
git checkout tags/X.XX.XX -b `origin-repo`
git branch --set-upstream-to origin/`origin-repo` `origin-repo`
git push origin `origin-repo`
git pull
应用私有差异
git checkout -b feat-diff
git apply feat-diff
git commit -m "applied feat-diff"
git push origin feat-diff
然后是 feat-diff 的拉取请求(在 GitHub UI 中)
带基数:origin-repo
我希望我的网络图看起来像这样:
master (upstream/master) ------------UM1--UM2--UM3--UM4--UM5------
\
legacy (upstream/legacy) UL1--UL2--UL3--UL4---------
\
origin-repo (origin/origin-repo) OR1--OR2-------OR3--
\ /
feat-diff (origin/feat-diff) FD1--FD2
相反,我得到了这张图。 (我的功能分支一直回到我使用的标签)
所以看起来我的主分支(origin-repo)是实际功能分支的功能分支,功能分支一直回到标签。
为什么会这样,我该如何解决?
So it looks like my main branch (origin-repo) is a feature branch of the actual feature branch
给定一个像
这样的提交结构
B <--(branch1)
/
A
\
C <--(branch2)
A
与这些分支中的任何一个分支之间没有特殊关系。也许 branch1
恰好被称为 master
。也许 branch2
被称为 feature
。也许 master
在 feature
创建之前就存在于 A
,但如果是这样的话 git
不记得也不关心那个细节。
要点是,"feature branch" 是一个描述性标签,对人们理解分支模型很有用。 不是git中的"physically real"概念。两个分支都是分支,仅此而已。
and the feature branch goes all the way back to the tag.
分支完全没有 "go back"。分支是指向提交的指针。您可能认为该提交是 "tip of the branch" 或类似的东西,但实际上分支就是这样。 "also part of the branch" 没有一条穿越历史的道路。可以有一条或多条历史路径可以从 分支 到达,但是这些相同的路径可能可以从另一个分支到达,并且路径和路径之间没有特殊关系任何一个分支超过另一个。
所以你真正得到的是你的可视化工具,试图迎合我们喜欢强加在分支上的抽象——比如路径之间的关系提交和分支 - "guessed wrong" 关于您希望看到的分支与历史路径的关联。
我不能告诉你为什么 "guessed wrong"。我可以告诉你它必须猜测,因为你想看到的关系不是真实的。
存储库设置
分叉一个私有存储库
克隆 public 回购到私人回购
git clone --bare git@github.com:`upstream`/`upstream-repo`.git
cd `upstream-repo`.git
git push --mirror git@github.com:`origin`/`origin-repo`.git
创建工作目录
git clone git@github.com:`origin`/`origin-repo`.git
git remote add upstream git@github.com:`upstream`/`upstream-repo`
git fetch upstream
删除除 master 和 legacy 之外的所有分支(为清楚起见)
git push origin --delete `all branches excpt. master and legacy`
设置远程跟踪分支
git branch --set-upstream-to upstream/master master
git branch --set-upstream-to upstream/legacy legacy
让主干分支成为来自上游的标签
There is no such thing as a "remote Git tag"
发件人:
所以标签是本地标签,可以用git fetch upstream --tags
从本地标签创建原始中继(名为 origin-repo
)
git checkout tags/X.XX.XX -b `origin-repo`
git branch --set-upstream-to origin/`origin-repo` `origin-repo`
git push origin `origin-repo`
git pull
应用私有差异
git checkout -b feat-diff
git apply feat-diff
git commit -m "applied feat-diff"
git push origin feat-diff
然后是 feat-diff 的拉取请求(在 GitHub UI 中)
带基数:origin-repo
我希望我的网络图看起来像这样:
master (upstream/master) ------------UM1--UM2--UM3--UM4--UM5------
\
legacy (upstream/legacy) UL1--UL2--UL3--UL4---------
\
origin-repo (origin/origin-repo) OR1--OR2-------OR3--
\ /
feat-diff (origin/feat-diff) FD1--FD2
相反,我得到了这张图。 (我的功能分支一直回到我使用的标签)
所以看起来我的主分支(origin-repo)是实际功能分支的功能分支,功能分支一直回到标签。
为什么会这样,我该如何解决?
So it looks like my main branch (origin-repo) is a feature branch of the actual feature branch
给定一个像
这样的提交结构 B <--(branch1)
/
A
\
C <--(branch2)
A
与这些分支中的任何一个分支之间没有特殊关系。也许 branch1
恰好被称为 master
。也许 branch2
被称为 feature
。也许 master
在 feature
创建之前就存在于 A
,但如果是这样的话 git
不记得也不关心那个细节。
要点是,"feature branch" 是一个描述性标签,对人们理解分支模型很有用。 不是git中的"physically real"概念。两个分支都是分支,仅此而已。
and the feature branch goes all the way back to the tag.
分支完全没有 "go back"。分支是指向提交的指针。您可能认为该提交是 "tip of the branch" 或类似的东西,但实际上分支就是这样。 "also part of the branch" 没有一条穿越历史的道路。可以有一条或多条历史路径可以从 分支 到达,但是这些相同的路径可能可以从另一个分支到达,并且路径和路径之间没有特殊关系任何一个分支超过另一个。
所以你真正得到的是你的可视化工具,试图迎合我们喜欢强加在分支上的抽象——比如路径之间的关系提交和分支 - "guessed wrong" 关于您希望看到的分支与历史路径的关联。
我不能告诉你为什么 "guessed wrong"。我可以告诉你它必须猜测,因为你想看到的关系不是真实的。