Forking using TFS Git

最后都变了- 提交于 2019-12-21 12:13:27

问题


I'm in a project now that uses TFS and 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%).

I was planning to Fork project "A" into "Client_A" and make the changes needed. 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.

My problem now is that Forking is not supported, we were using bitbucket before in my team. 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?


回答1:


If you remove the upstream remote (A), it cannot work.

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.

UPDATE: The Fork feature is available in VSTS or TFS 2018 and later (see https://docs.microsoft.com/en-us/vsts/git/concepts/forks).



来源:https://stackoverflow.com/questions/30617620/forking-using-tfs-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!