Cant create a branch from a TFS project - tfs

I started using TFS and I was not using branches for my project, but now I need to manage releases, so my Idea is to make Branch from the project and for every release create new branch from the main branch.. so
In VS2015 Source Control Explorer, i click on TFS project > Branching and Marging > Convert To Branch and this error happened
TF203028: You cannot create a branch at $/ProjectA because a branch alreadyexists at $/ProjectA/Main. If $/ProjectA/Main is not a branch convert it back to a folder and retry the operation.
the problem is that I don't see any branches in source control manager neither in TFS website, I created empty branch earlier but I deleted it. What to do ? I don't want to create new project with Main branch and copy/paste the source codes because I want to preserve the commits.

In TFS, you never really delete anything. In fact, if you look under Tools -> Options -> Source Control -> Team Foundation Server, there is an option to show deleted items:
To actually delete an item, have a look at the tf destroy command.
I believe that you can simple rename the folder, and that will maintain your history, should you not wish to permanently delete the old branch.

Related

How do I branch?

https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/branching-strategies-with-tfvc?view=azure-devops
I have a brand new project in Azure DevOps. There's nothing in it yet, but I want to set up the branches to model the Servicing, Hotfix, Release isolation strategy from the link above.
To do this, I need a branch, and a branch of a branch.
When I right click my project and say "Branch", it prompts for a Target.
This is where everything I try does not work.
First thing I tried was to use $/Master/HotFix. This returns an error "The target item $/Master/HotFix cannot be under the source item $/Master.
Then, I tried just $/Master-HotFix and get an error "Source control must branch into an existing team project. Master-HotFix is not a team project"
So, I went to Azure DevOps and I created a new project called Master-HotFix. I mapped it in Visual Studio, and tried again. This time, I got the error "Unsupported pending change attempted on team project folder $/Master-HotFix. Use the Project Creation Wizard in Team Explorer to create a project.
Surely making a branch isn't this difficult? What am I missing?
According to your description, seems you get promoted a kind of below dialog
I have a brand new project in Azure DevOps. There's nothing in it yet
You are trying to branch a Team Project rather than a folder containing your code.
You should first have your code in a folder, say "Master", under the "$/TeamProject/" folder. You can then branch "$/TeamProject/Master" to "$/TeamProject/Master/child".
If you have dumped all of your code into the root of your team project then you will need to move it into a folder first, then branch that folder.
warning: You can create a new team project that is a branch of this one, giving you "$/Master". However this method is a terrible idea and will lead to pain and suffering
For more details please refer our official tutorial:
Convert a Folder to a Branch
Branch a folder or file
In order to branch in TFVC you first need to create you master/MAIN branch as a folder. Then you check that folder in. After you can convert it to a branch from the branch menu. After that you'll be able to branch off that master/MAIN branch and create the structure you are trying to do.
Cheers,
ET

Teamfoundationserver branching not working in any form

I have tried branching in a very simple sample project and it worked. Now I want to branch a real life project and it is simply not working.
When I try to branch the whole team project, tfs tells ask for a destination. If I choose a new destination it tells me, that the destination does not exist. If I create a new one and point to it, it tells me that the folder already exists.
When I try to branch the team project into a sub-folder within the team project it tells me that this procedure cant be done, fair enough.
But when I try to branch a single project within the team project to another sub-folder it tells me that there was no correct mapping ('keine passende Zuordnung', in German I don't know the exact English error message).
Any help on this is very appreciated. I fail to see, what I do differently here, then I did before in my test project.
Edit: As suggested I post an image of my project structure. The upper folder is my actuall project which I have converted from a teamproject to a branch. The second on is the destination folder which is empty.
When branching a whole team project ($/ProjectName), you either need to use the New Project Wizard to create a new project and specify that it should branch from your current project.
When branching a sub-folder of your team project, that should work, unless a parent of that sub-folder is marked as a branch root, in which case there is no location to branch to.
Any folder that either holds a branch root as a child, or has abranch root as a parent cannot be used to create a new branch:
On the commandline try running tf branches . from the folder that you want to branch (to see if it is part of a branch) and from the folder you want to branch to. If the target folder is already under a branch, you can't branch to it. You might need to use the Convert to Folder option in the Source control explorer to allow branches to be created there.
It looks like you've already created the target folder, and the target folder is already a branch. You haven't described how that came to be, if it's a result from a Branch action on the source folder, then instead of choosing Branch pick Merge instead.
If there is no relationship between the two folders then it won't be pre-populated in the list of possible merge targets. If you're using Visual Studio 2013 you can enter the path manually and TFS will create the relationship by doing a baseless merge. If you're using an older version of Visual Studio you may need to create this relationship from the commandline:
tf merge "$/TeamProject/Machinenzustandsanzeige" "$/teamproject/Machinenzustandsanzeige NC-Prä" /baseless /recursive /collection:{uri}
You can also destroy the target branch that you've created using the commandline and then re-attempt the branch, which should then succeed.
tf destroy "$/teamproject/Machinenzustandsanzeige NC-Prä" /recursive /collection:{uri}
tf branch "$/teamproject/Machinenzustandsanzeige;T" "$/teamproject/Machinenzustandsanzeige NC-Prä" /recursive /collection:{uri}
tf checkin "$/teamproject/Machinenzustandsanzeige NC-Prä" /recursive /collection:{uri}
In case the workspace isn't setup correctly yet you can either do it through the UI using the steps outlined here or from the commandline using:
tf workfold /map "$/teamproject/Machinenzustandsanzeige NC-Prä" c:\path\where\you\want\it
followed by:
tf get "$/teamproject/Machinenzustandsanzeige NC-Prä" /recursive
to effectuate the addition of the folder.
There is a very slim chance that the a-umlaut is causing the issue. Have you tried a path without special characters?
What you want to achieve is a standard operation and TFVC supports it, but somehow you ended up in a situation that is non-default. Even in such a situation you can get it fixed, but you might need to resort to advanced features such as /baseless or /force or tf destroy which are not available from the UI.

TFS - How to promote code to prod branch without merging

We have 3 TFS branches – dev, test, and prod.
TFS works well for us as source control as long as we check in and get latest often. Then the merging is small and we can resolve any issues right away. We know that if we don’t do this every day, then merging our code will be painful.
But by the time we are ready to promote to one of the other branches, there are huge changes in the code. We don’t want to keep any of the code in the target branch, and we really do want an exact copy of the source version, not a merge.
We do like having the 3 branches so that change sets are kept for the complete set of changes in each deployment/promotion.
I don’t see a way in TFS to do this very common function. I have been using two workarounds:
If only one user does the merging from one branch to the next, TFS really does copy all changes. But it does not work if the user is different than the last user attempting the promotion, then TFS will merge the code.
I have checked out the whole solution of my local copy of the target branch. Then done a file system copy of the source branch folder into the target branch folder. Then checked in the solution.
Is there a right way?
The correct way to merge is:-
Set up a shared workspace that contains both branches (if you don't already have one)
Get the latest Target branch code
Get the latest Source branch code
Merge from your Source to your Target using Latest Version and All Changes to a Specific Version
Submit your Changes to Source
To overwrite the target if you get conflicts, to ensure that the target is definately overwritten, Select Choose Source version at the conflict window
I know this post is way late, but
My solution in this scenario
Prod -> Dev -> Test
(parent) -> (child) -> (grandchild)
When test is ready to be promoted, I do the following.
Delete Prod (This can be undone with rollback, but check-in)
Branch Test -> Prod (Use the same name a location as the old deleted version), so your new branch structure will be Dev -> Test -> Prod
Reparent Prod (new branch) to "none"
Reparent Dev to Prod
Delete Test
Branch Dev -> Test
When you look at the new branch hierarchy it will look the same as when you started but the code in prod will be the same as Test.

In TFS, Cannot Reparent a folder that was converted to a branch

We have a TFS branch structure like Main > Integration > Several Branches under this.
The problem is that I created a folder 'feat-IIS6toIIS7Migration'outside the above hierarchy when I started coding. After finishing coding I converted the folder to a branch.
But the new branch has no parent and I want to put it under Integration. It seems that its impossible to do this in TFS, since when I try to re-parent I get an empty list of possible parents. Is there a way to put the new branch under Integration?
If you want the folder to appear under the integration branch then you can just move it (right click in Source Control explorer and select move).
$/Root/Integration
$/Root/feat-IIS6toIIS7Migration
becomes
$/Root/Integration/feat-IIS6toIIS7Migration
When the integration branch gets merged with either main or your development branches the folder will be added to those branches as part of the merge.
If you want to give the feat-IIS6toIIS7Migration folder a branching relationship with integration then you need to perform a baseless merge. Note you should only do this if the feat-IIS6toIIS7Migration folder is a full replication of the integration branch.
In TFS / VS 2012 you can perform a baseless merge from the GUI.
Right click on the integration branch in Source control explorer and
select merge. This will be your source branch.
In the target branch dropdown you won't be able to see the
feat-IIS6toIIS7Migration folder.
Select "Browse" and then navigate to the location of the
'feat-IIS6toIIS7Migration' folder.
Keep hitting next until VS performs the merge.
I would expect there to be a fair few merge conflicts and you'll need to resolve a lot of them manually.
In the future it would be better to create the branch for your development before you start work, then you can take regular merges so you don't have a big merge at the end of your development.

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.

Resources