使用TFS Git进行分叉

Bea*_*tad 7 git tfs github git-fork

我现在在一个使用TFS和Git的项目中.而且我意识到我不再能够分叉了,所以我想我会问你们你们对此的看法是一个解决方案.

我遇到的问题是我有一个"基础"项目.这将重新用于我们拥有的每个客户.但每个客户都有一定程度的修改(约5-10%).

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

我现在的问题是不支持Forking,我们之前在团队中使用了bitbucket.但是既然我们现在已经与公司其他部门整合在一起,那么我们需要运行其他人正在运行的东西......

这就是我在想的事情......

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
Run Code Online (Sandbox Code Playgroud)

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

Giu*_*ian 10

如果删除上游remote(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
Run Code Online (Sandbox Code Playgroud)

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

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