Merge two TFS branches with git tfs

ぃ、小莉子 提交于 2019-12-20 12:05:27

问题


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 & $/MyCompany/Release-3.3. Release-3.3 originates from the Dev branch. Both are checked out as different git repositories using git tfs.

I'd like to re-incorporate the changes back into the Dev branch. Can this be achieved with git-tfs or will I have to resort to trying to do it using TFS tools?


回答1:


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...




回答2:


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



回答3:


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



来源:https://stackoverflow.com/questions/8559814/merge-two-tfs-branches-with-git-tfs

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