TFS Branching / Versioning Basics - tfs

I am very new to TFS. I have below Structure where I have my entire SOLUTION checked into my TFS online Repository.
Now, we are done with this Feature/Version.
What we want to do is...Leave this version AS IS and create a new Version / Branch out of this. This way if we ever have to go back to this version we can easily go back to it.
But Whenever I right Click on Root and Choose "Branch" Then I get an error that "The Bracnh Already Exists". I would like to name the new Branch "Release 2.0" or Something. But I cant Branch out my current Solution.
Creating New Folder option is Disabled.
Why is it disabled? I have full access to TFS/

You can't branch from the team project root. Reorganize everything to be in a trunk folder (TFVC convention is main, but you can call it whatever you want), and branch off of that.
For what it's worth, branches shouldn't be infinitely branching -- you should branch off of a trunk to do development, then merge back in when development is done. There are numerous reasons why this is the case, but I suggest doing some reading on TFVC branching strategies to find one that's appropriate for your organization.

Related

Change default branch path name in TFS 2013

We have a trunk branch in TFS called Main. From that we create bug/feature branches that should go into their own folder. We had created a folder called Development for this purpose, so when we branched we would specify...
$/TFS/Development/{branchname}
However, we noticed TFS defaulted the path to...
$/TFS/Main-branch
So we thought, we'll just rename Development to Main-branch and life will be good. And we did.
Now the problem is TFS defaults the path to...
$/TFS/Main-branch1
I realize this is severely in the "first world problem" category, but is there a way to change the default path TFS uses? I have found other SO posts that indicate this cannot be done, but I was hoping there was something we could do for TFS2013.
There is no way to change this behavior without code.
It is the same behavior as creating a new folder in windows explorer and it being "NewFolder"...
It's kinda deliberate so you give it a proper name 😊

Copy new directory from one TFS branch to another

Another developer has some test files in a new directory in their branch. They're useful to me as well but I'm working in a totally independent, newer branch and he's not likely to merge his branch anytime soon.
I am able to branch his "test-data" directory into my branch but I really want to break the branch association so they're treated as new files in my branch, i.e. so TFS thinks our branches independently added the same new files and we resolve conflicts later since our test data is likely to diverge.
Is there a way to "orphan" the branched files somehow?
You can just get files in TFS using the web access component. Just browse to the folder through the code portion of web access and right click > get as zip.
You can do it from the command line as well but I am not familiar with that. SO has a lot of resources on how to do that from what I have seen.
It is possible to break the branching relationship in TFS and there are many questions on SO on how to do that. But your branch wouldn't initially treat them as 'added' and the history will be in TFS. I would recommend branching just the folder his useful code into your branch and leaving that relationship for posterities sake.
That being said, depending on your situation it may not make sense. If you want to remove the branching relationship immediately, then I don't think you need to use TFS.

TFS2010, is it possible to create a branch retroactively?

Been using TFS2010 for just a few months now so relative newbie, and now possibly need to create my first branch, unfortunately I need to create it from an older changeset, is this possible?
Basic scenario is I converted a project from VSS 6.0, with history, and it all came over fine. Project has approx 500 source files.
Before the conversion from VSS we started working on version 4.0 of our project, with no plans to release any more bug fixes to 3.1 so we didn't establish any branches at that time.
So we have made significant changes to about 20 files (which I can identify), but now the client wants to release a 3.11, 3.2, 3.3 etc because not everyone will be ready to go to 4.0 product anytime soon.
I think we want to create a branch, and then use TFS to rollback about 20 files in that branch to an older version, is this possible to do? Create a branch from where we are now, and then rollback some of the files? or does creating a branch cause you to lose history for that branch?
Slightly complicating things is that after we started working on 4.0, besides making the 4.0 specific changes we also have several changes that we made that would need to go into both he 3.1 branch AND stay in the 4.0 branch we are working on now, and furthermore, and more bug fixes we need to put in over the next several months would need to apply to both branches.
Perhaps this is a pretty straight-forward use case for TFS, but just wanted to make sure I don't mess up what is already working perfectly fine.
Suggestions?
You can create a branch from any changeset, and it's very easy from within the Source Control Explorer UI. Just navigate with Source Control Explorer to the server path you want to branch, select branch, and then you'll be given the option to "Branch From Version". Just select whatever changeset you want to branch from and your new branch will be created from that instead of the default of the latest version.
Why don't you choose to get the appropriate base version with "Get Specific Version" which will summon the sources in the state you need - of your version 3.1.
Then construct a branch to continue work towards 3.1x
Executing 'Get Latest' on your base branch should result with your sources in version 4.0
I have just done this.
I started my solution with a single branch team project in codeplex :
-MyPrettyCMS/Database
-MyPrettyCMS/Framework
-MyPrettyCMS/Layers
-MyPrettyCMS/Portals
-MyPrettyCMS/Solution
It's not possible to create a branch of the team project
WARNING ! I tryed to convert Team Project folder to a Branch, it worked but after that, I can't create any branch and I had not enough rights to undo that (I had to ask the Code Plex TFS Administrator to undo for me).
All of this must be done with team explorer and not with solution explorer.
So I created a Team project folder subfolder CurrentRelease like this
-MyPrettyCMS/Database
-MyPrettyCMS/Framework
-MyPrettyCMS/Layers
-MyPrettyCMS/Portals
-MyPrettyCMS/Solution
-MyPrettyCMS/CurrentRelease
Then, for each folder I used the team explorer move command (DON'T MOVE FOLDERS with the Windows explorer even if you have the plug in, because sometimes it fails).
The result is
-MyPrettyCMS/CurrentRelease/Database
-MyPrettyCMS/CurrentRelease/Framework
-MyPrettyCMS/CurrentRelease/Layers
-MyPrettyCMS/CurrentRelease/Portals
-MyPrettyCMS/CurrentRelease/Solution
At this point you must archive each CurrentRelease subfolder
Now you open windows explorer and you verify each folder and its descendent to see if you forgot some files. If you did, copy it to the new folder, add it to archive with the Add files of Team Explorer. You must archive again.
Right click on MyPrettyCMS/CurrentRelease ans select command create a branch
I used CurrentRelease-To-2-50-001 as Branch name
Then I have
-MyPrettyCMS/CurrentRelease/Database
-MyPrettyCMS/CurrentRelease/Framework
-MyPrettyCMS/CurrentRelease/Layers
-MyPrettyCMS/CurrentRelease/Portals
-MyPrettyCMS/CurrentRelease/Solution
and
-MyPrettyCMS/CurrentRelease-To-2-50-001/Database
-MyPrettyCMS/CurrentRelease-To-2-50-001/Framework
-MyPrettyCMS/CurrentRelease-To-2-50-001/Layers
-MyPrettyCMS/CurrentRelease-To-2-50-001/Portals
-MyPrettyCMS/CurrentRelease-To-2-50-001/Solution
I archived the Initial version of the branch.
Now I can work on my next release and make some minor corrections to the current release.

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

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:
Rename Develop to Main (creating Main --> Release)
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.
I'm preparing to do similar steps (except I'm moving subfolder locations of both parent and a child while grandchildren stay put.)
QUESTIONS:
When are you planning the rename?
Are there any child branches under Develop branch that you didn't mention?
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:
Rename Develop to Main ==> Branch Main branch from Develop, then delete Develop branch
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:
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 :)
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
Get all devs to merge (or abandon) all safe changes in child branches of Dev. Also prune any inactive branches before the rename.
Read above articles.
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.)
You might consider making a "Sandbox" Team Project (or Team Project Collection) then try out your scenario to see if there are major issues.
Pick right timing (see link#1) and go for it.
Check history, do a merge between the renamed branches, check history again.
Allow developers back in.
Good luck, and post back with any new information (including your end results)! -zs

How can I view the history on the trunk from my branch

View History on an file in a branch show only changes since the branch. I need to go back further -- like how created the file in the first place. I've also tried Sidekicks, and it doesn't seem to show history from before the branch either.
Short of hunting down the file in the trunk manually, is there a way to view a file's history from the time it was added to now following the path in the branch?
You can upgrade to TFS 2010 for this support natively. The 2010 upgrade is well worth the time for many reasons, this being one of them.
I've used an addon TFS follow branch history the UI is a bit clunky but will get you what you're looking for. It only shows the branched history for a file but won't recurse to all files in a directory.

Resources