Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forking using TFS Git

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?

like image 980
Beau Johnny Bekkestad Avatar asked Jun 03 '15 10:06

Beau Johnny Bekkestad


Video Answer


1 Answers

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://learn.microsoft.com/en-us/vsts/git/concepts/forks).

like image 171
Giulio Vian Avatar answered Oct 12 '22 19:10

Giulio Vian