简体   繁体   English

使用TFS Git进行分叉

[英]Forking using TFS Git

I'm in a project now that uses TFS and Git. 我现在在一个使用TFS和Git的项目中。 And i've realized that i am not going to be able to Fork anymore so i thought i would ask you guys what you think about this as a solution. 而且我意识到我不再能够分叉了,所以我想我会问你们你们对此的看法是一个解决方案。

The problem i am having is that i have a "Base" project.That would be reused for every client we have. 我遇到的问题是我有一个“基础”项目。这将重新用于我们拥有的每个客户。 But each client has modifications to some extent (about 5-10%). 但每个客户都有一定程度的修改(约5-10%)。

I was planning to Fork project "A" into "Client_A" and make the changes needed. 我计划将项目“A”分叉到“Client_A”并进行所需的更改。 All the classes where changes can be made are implementations of Abstract classes in "A", so i would be able to sync a new version of A as long as dependencies are met. 可以进行更改的所有类是“A”中抽象类的实现,因此只要满足依赖性,我就能够同步新版本的A.

My problem now is that Forking is not supported, we were using bitbucket before in my team. 我现在的问题是不支持Forking,我们之前在团队中使用了bitbucket。 But since we were integrated with the rest of the company now we need to run what everyone else is running... 但是既然我们现在已经与公司其他部门整合在一起,那么我们需要运行其他人正在运行的东西......

This is what i am thinking about doing... 这就是我在想的事情......

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

If i do this will i still be able to upstream to A? 如果我这样做,我还能上游到A吗?

If you remove the upstream remote ( A ), it cannot work. 如果删除上游远程( A ),则无法正常工作。

Probably you want something like 可能你想要类似的东西

# 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 client cannot create the repository in TFS, you need to do it manually via the Web interface or using my TfsGitAdmin utility. Git客户端无法在TFS中创建存储库,您需要通过Web界面或使用我的TfsGitAdmin实用程序手动完成

UPDATE: The Fork feature is available in VSTS or TFS 2018 and later (see https://docs.microsoft.com/en-us/vsts/git/concepts/forks ). 更新: Fork功能在VSTS或TFS 2018及更高版本中可用(请参阅https://docs.microsoft.com/en-us/vsts/git/concepts/forks )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM