简体   繁体   English

使用git tfs合并两个TFS分支

[英]Merge two TFS branches with git tfs

I'm using git-tfs , and I was wondering if it is possible to merge two TFS branches using git-tfs . 我正在使用git-tfs ,我想知道是否可以使用git-tfs合并两个TFS分支。 I have two branches $/MyCompany/Dev & $/MyCompany/Release-3.3. 我有两个分支$ / MyCompany / Dev&$ / MyCompany / Release-3.3。 Release-3.3 originates from the Dev branch. Release-3.3源自Dev分支。 Both are checked out as different git repositories using git tfs. 两者都使用git tfs检出不同的git存储库。

I'd like to re-incorporate the changes back into the Dev branch. 我想将更改重新合并到Dev分支中。 Can this be achieved with git-tfs or will I have to resort to trying to do it using TFS tools? 这可以通过git-tfs实现,还是我不得不尝试使用TFS工具来实现?

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! 从git-tfs 0.16开始,您可以管理TFS分支(使用branch命令),因此您现在可以轻松地初始化现有分支,创建一个并合并TFS分支!

https://github.com/git-tfs/git-tfs/blob/master/doc/commands/branch.md#initialize-an-existing-tfs-branch 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 从版本0.19开始,您可以对2个TFS分支进行git合并并在TFS中签入(使用rcheckin),它将作为合并变更集进行检查: https//github.com/git-tfs/git- TFS /斑点/主/ DOC /命令/ rcheckin.md#签-A-合并-变更

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. 唯一的限制(由于TFS)是在与git合并之前已经在TFS中检查过所有提交并在TFS中检查它。

So you can now merge more easily than with 2TFS branches and check them in... 因此,您现在可以比使用2TFS分支更容易合并并检查它们...

I found an awesome, if hacky way of doing this. 我找到了一个很好的,如果hacky这样做的方式。 Git tfs manages it's awareness of areas of TFS using git config. Git tfs使用git config管理它对TFS区域的认识。 Specifically 3 attributes per remote ; 每个remote特别有3个属性 url, repository and fetch, for example: url,repository和fetch,例如:

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 . 您可以通过使用不同的名称再次将这3个属性设置为default来添加另一个remote 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. 您可能需要立即发出git tfs bootstrap

You can then issue: 然后你可以发出:

git tfs fetch -i feature_branch

Then merge the commits using: 然后使用以下方法合并提交:

git merge tfs/feature_branch

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). 我不是git-tfs用户,但我过去用git-svn做过这个(我相信有类似的方法)。 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. 如果将两个远程分支添加到同一个git仓库,则应该能够进行本地合并,执行本地提交,然后将该提交推送到TFS。

HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM