使用 TFS 分叉 Git

Forking using TFS Git

我现在在一个使用 TFS 和 Git 的项目中。而且我已经意识到我不能再使用 Fork 了,所以我想问问你们,你们是怎么看待这个解决方案的。

我遇到的问题是我有一个 "Base" project.That 将被我们拥有的每个客户重复使用。但是每个客户都有一定程度的修改(大约5-10%)。

我正计划将项目 "A" 分叉到 "Client_A" 中并进行所需的更改。 所有可以进行更改的 类 都是 "A" 中抽象 类 的实现,因此只要满足依赖关系,我就可以同步 A 的新版本。

我现在的问题是不支持分叉,我们之前在我的团队中使用的是bitbucket。但由于我们与公司其他部门整合,现在我们需要 运行 其他人 运行ning...

这就是我正在考虑做的...

git clone http://mycompany.com/tfs/MyDefaultCollection/My Git Projects/_git/A
cd A
git fetch origin
git branch -a
git checkout -b a_branch1 origin/a_branch1
git checkout -b a_branch2 origin/a_branch2
git checkout -b a_branchN origin/a_branchN
git branch -a
git remote add new-origin http://mycompany.com/tfs/MyDefaultCollection/My Git Projects/_git/Client_A
git push --all new-origin
git push --tags new-origin
git remote rm origin
git remote rename new-origin origin

如果我这样做,我还能上游到 A 吗?

如果移除上游遥控器 (A),它将无法工作。

可能你想要这样的东西

# 1. create Client_A repo in TFS
# 2. get A repo locally
git clone http://mycompany.com/tfs/MyDefaultCollection/My Git Projects/_git/A
cd A
# 3. redefine remotes
git remote rename origin upstream
git remote add origin http://mycompany.com/tfs/MyDefaultCollection/My Git Projects/_git/Client_A
# 4. push to Client A
git push origin
# 5. push to A (when proper)
git push upstream

Git 客户端无法在 TFS 中创建存储库,您需要通过 Web 界面或使用我的 TfsGitAdmin 实用程序手动创建。

更新: Fork 功能在 VSTS 或 TFS 2018 及更高版本中可用(请参阅 https://docs.microsoft.com/en-us/vsts/git/concepts/forks)。