Teamfoundationserver branching not working in any form - tfs

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.

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

Cant create a branch from a TFS project

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.

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.

TFS Unmerged Changes

I use a simple branching strategy where I have a trunk. i branch from that trunk into multiple development branches. Once dev is done I merge the dev branch back into main.
I'm looking for a way to produce an automated report that would tell me which branches have changes that have not yet been merged back into the trunk.
I'm sure there is a way to do this with either tf.exe or the tfs database.
I found Derek's answer to be correct, but there was a small syntax problem in the call to tf.exe.
The correct syntax is:
tf.exe merge /recursive /candidate "$/Source/Branch/Location" "$/Target/Branch/Location"
This should be run from within a mapped TFS workspace folder, or you may get the error: "Unable to determine the workspace."
You can alternatively use the "workspaces" action on tf.exe before the merge call to specify a collection to target if the machine you're running from has no mapped workspaces.
You could use the API... but it would be easiest to just use tf.exe. I used to have a Powershell script that I executed once each development cycle to catch unmerged changes.
Use with vc or git (below example for vc):
tf.exe vc merge /recursive /candidate "$/source/BRANCH" "$/target/BRANCH"
You can get the skinny on all of the tf.exe merge options here:
http://msdn.microsoft.com/en-us/library/bd6dxhfy(v=vs.100).aspx

TFS: Overwrite a branch with another

Is it possible overwrite a branch with another?
Or is the only solution to delete branch B and make a new branch from Branch A?
Unless you're running TFS 2010, I'd recommend using Merge + Resolve to bring the two branches back in sync.
# cancel out of conflict dialog
tf merge A B -r -force -version:T
tf resolve B -r -auto:acceptTheirs
That should equalize everything, except for files that were only created in B and never merged back. Use Folder Diff to find & reconcile them.
Delete + rebranch in 2005/2008 runs the risk of nightmarish-to-debug namespace conflicts in the future. The other option, if you have 2008, is to Destroy + rebranch. Obviously that assumes you are ok with losing all the history from the original copy of B.
In Visual Studio 2010, I just used the baseless merge to achieve this:
Tf merge /baseless [source path] [target path] /recursive
When the resolve conflicts window popup, select 'Take source version' option. Note, the files only exist in target will not be deleted by using baseless merge, but you can compare the 2 branches to identify the difference and delete them manually.
Refer to: http://msdn.microsoft.com/en-us/library/bb668976.aspx
I had success using Richard Berg's answer but felt like there were a few details that were missing. This is how I was able to eliminate differences related to conflict resolutions and changesets that had not been merged back to the source and make the target identical to the source. Note that this is how I will be referring to the branches - source is the one that should not be changed while target is the one that should be made identical to source.
Make sure that you have the latest version of both the source and target branches in your workspace. Also make sure that you do not have any pending changes.
Discard all of the candidates for merges from the target branch to the source branch. This is to prevent any of these differences from being unintentionally merged back into the source branch later on.
tf merge $/target $/source /recursive /discard
Note: Make sure that you have set the working folder to a path within your workspace so that the tf tool knows which workspace and TFS server to use.
Check that there are differences between the branches that should be addressed - if not, no further action is required.
3.1. View history on the target branch and find the last complete merge from the source to the target (ignore any cherry picking merges as that will result in lots of false positives) - note the changeset number. An easier alternative would be to perform a merge from the source branch into the target branch to get the lastest version from the source branch into the target branch.
3.2. Right click on the source branch in the Source Control Explorer and select Compare from the context menu. Only take the latest version for the source if you merged the source branch into the target branch in step 2.1. Otherwise select Changeset from the Source Version | Type combo box and then enter the changeset number from step 2.1.
3.3. Use the drop down arrow on the Browse button next to the Target Path field to select Server Path. Then select the target branch in the dialog that opens.
3.4. Click OK on the Compare dialog to perform the comparison.
Perform a merge from the source branch to the target branch and pass the force option. This will ignore the merge history and merge changesets even if they have been merged in the past.
tf merge $/source $/target /recursive /force /version:T
Note: the T version specification indicates the latest version.
Close the merge conflicts dialog.
Automatically resolve all conflicts by choosing the source branch.
tf resolve $/target /recursive -auto:TakeTheirs
Check in.
Confirm that there are no longer any candidates for merges from the target to the source and that there are no differences between the two branches (this time just using the latest versions as we did a forced merge of the latest version in step 4.).
See MSDN for more details on the tf merge and resolve commands.
Delete the branch B and create a new one from branch A.
Is there a reason why you do not want to do this?

Resources