Merge two TFS branches with git tfs

后端 未结 3 1738
难免孤独
难免孤独 2021-02-05 14:51

I\'m using git-tfs, and I was wondering if it is possible to merge two TFS branches using git-tfs. I have two branches $/MyCompany/Dev & $/MyCompan

相关标签:
3条回答
  • 2021-02-05 15:19

    I found an awesome, if hacky way of doing this. Git tfs manages it's awareness of areas of TFS using git config. Specifically 3 attributes per remote; url, repository and fetch, for example:

    tfs-remote.default.url=http://tfsserver:8080/tfs/collection
    tfs-remote.default.repository=$/Product/Branch/Component
    tfs-remote.default.fetch=refs/remotes/default/master
    

    You can add another remote by setting these 3 properties again with a different name to default. Eg:

    tfs-remote.feature_branch.url=http://tfsserver:8080/tfs/collection
    tfs-remote.feature_branch.repository=$/Product/FeatureBranch/Component
    tfs-remote.feature_branch.fetch=refs/remotes/default/feature_branch
    

    You may need to issue git tfs bootstrap now.

    You can then issue:

    git tfs fetch -i feature_branch
    

    Then merge the commits using:

    git merge tfs/feature_branch
    
    0 讨论(0)
  • 2021-02-05 15:19

    I'm not a git-tfs user, but I have done this with git-svn in the past (which I believe has a similar approach). I think your main issue is that you have two repos. If you add both remote branches to the same git repo, you should then be able to do a local merge, do a local commit and then push that commit to TFS.

    HTH

    0 讨论(0)
  • 2021-02-05 15:23

    Since git-tfs 0.16, you can manage TFS branches (with branch command) so you can now easily init existing branch, create one and merge TFS branches!

    https://github.com/git-tfs/git-tfs/blob/master/doc/commands/branch.md#initialize-an-existing-tfs-branch

    And since the release 0.19, you can do a git merge of 2 TFS branches and checkin it in TFS (with rcheckin) and it will be checked in as a merge changeset : https://github.com/git-tfs/git-tfs/blob/master/doc/commands/rcheckin.md#checkin-a-merge-changeset

    The only limitation (due to TFS) is that all the commits should have been already checked in TFS before doing your merge with git and check it in TFS.

    So you can now merge more easily than with 2TFS branches and check them in...

    0 讨论(0)
提交回复
热议问题