Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename a branch and then reuse the name for a new branch?

Tags:

branch

tfs

Currently we have a branch structure like this: Develop --> Release. I want to change it so that it looks like what the TFS Branching Guidance document calls "Basic Branch Plan". It looks like this Develop <-- Main --> Release.

I was going to do this:

  1. Rename Develop to Main (creating Main --> Release)
  2. Creating a branch from this Main reusing the "Develop" name (creating Develop <-- Main --> Release)

Will I have problems with TFS reusing an old branch name for a new branch? Know any gotchas or things to look out for?

Additional Info I did this in a test instance creating test branches without any files, pending changes, history, etc. (not a good real test) and TFS let me do the rename and branch without difficulty. However, I won't feel comfortable with this unless I can take our production TFS project collection, restore it in the test instance, and test the rename/branch on real data. There is a lot of history and branches there and I don't know what will happen. As noted in the answer, there are other considerations before doing this.

like image 818
Jon Avatar asked May 05 '11 15:05

Jon


1 Answers

I'm preparing to do similar steps (except I'm moving subfolder locations of both parent and a child while grandchildren stay put.)

QUESTIONS:

  1. When are you planning the rename?
  2. Are there any child branches under Develop branch that you didn't mention?
  3. Do you have any shelvesets against Develop that might be impacted by the rename?

General answer: Proceed with caution. From my reading branch renaming in TFS2010 can cause a few unexpected side effects. TFS will be doing the following steps (under the hood) for your scenario:

  1. Rename Develop to Main ==> Branch Main branch from Develop, then delete Develop branch
  2. Create new "Develop" branch from Main

I recommend reading the following posts:

Renaming Branches in TFS 2010 (ChandruR’s Blog)

"MSDN Blogs > ChandruR's Blog > Renaming branches in TFS 2010 So my recommendations for this case:

  1. Avoid renaming branches - a cleaner solution would be to, at the right point in your release merge all changes to a parent branch and then re-branch to create a new branch hierarchy.

Or for the brave of heart :)

  1. You will need to time the rename of your branch, to a point in your release where you can merge to all related branches. The steps to follow are: ..."

Renaming branches in TFS2010 - But it works on my PC!

“In TFS 2010 behind the scenes a rename is actually a branch and delete process, this meant we ended up with the new branch, but also a deleted branch of the old name. This is not obvious unless you have ‘show deleted items in source control explorer’ enabled…”

"Now implemented as a branch + delete behind the scenes (new name is branched from the old, then the old name is deleted). This allows traceability in History, but allows us to get around the problems with merging renames (see Add, Rename, Add scenario). "

.

RANDOM THOUGHTS

  1. Get all devs to merge (or abandon) all safe changes in child branches of Dev. Also prune any inactive branches before the rename.
  2. Read above articles.
  3. Search to find the page (that I haven't found yet) that describes exactly what will happen in simpler terms based on real experience. Specifically I'd like to know what happens to shelvesets on the Develop branch after it is renamed to Main. (Next step can answer this.)
  4. You might consider making a "Sandbox" Team Project (or Team Project Collection) then try out your scenario to see if there are major issues.
  5. Pick right timing (see link#1) and go for it.
  6. Check history, do a merge between the renamed branches, check history again.
  7. Allow developers back in.

Good luck, and post back with any new information (including your end results)! -zs

like image 132
Zephan Schroeder Avatar answered Oct 16 '22 23:10

Zephan Schroeder