开发者

TFS 2010: How to re-branch using same name but different source branch?

开发者 https://www.devze.com 2023-03-28 21:42 出处:网络
The team I recently joined has the following TFS branch structure (abstracted): Main Foo branched from Main

The team I recently joined has the following TFS branch structure (abstracted):

  • Main
  • Foo branched from Main
  • Bar branched from Foo

I need to blow away Bar and essentially re-branch it directly from Main, rather than from Foo. I do not need to maintain the existing revision history in Bar.

The seemingly logicial and simple thing to do would be to simply delete Bar and re-create it as a branch from Main, however I ran across a blog post from one of the TFS MVPs indicating that deleting/re-creating a branch using the same name is bad ju开发者_如何学C-ju.

So... what should I do? Is there a way to re-target a branch without deleting it? It's worth noting that the name of the Bar branch needs to stay the same, for various reasons.


Re-targeting branches is not easily done in TFS. I think branching and merging is very, very limited in TFS compared to other VCS-es.

We have on several occations done what you are describing, without noticing any problems. However, I cannot guarantee that you will avoid the problems. Is moving to another TFS project an option? Then you can merge Main to the new project, and branch out a new "Bar" there? Probably not an option...


You have a couple of options, if you want to keep bar, but change it's relationship with main you could reparent the branch. First you need to do a baseless merge from main to bar

Tf merge /baseless $/teamproject/main $/teamproject/bar

Check in the pending changes.

Once the main and bar branches have a merge relationship you can reparent the branch in source control explorer. Right click on bar, select "branching and merging" and then "reparent". You should now be able to select main. See this blog for more information.

If the history isn't important then you could "destroy" the branch rather than deleting it. This should avoid the issues described in the blog you mentioned. Use the "tf destroy $/teamproject/bar" command line.

As the name suggests destroy is permanent so use with extreme care, once you've destroyed the branch then you shouldn't have any problems re-branching.

0

精彩评论

暂无评论...
验证码 换一张
取 消