Grant VSTS user access to create new branches - tfs

How do I grant a VSTS (TFVC) user access to create new branches from a branch? I already granted him "Manage branch" and "Merge" permissions on the ParentBranch.
When he tries to create a new branch named "ChildBranch" from "ParentBranch", he gets the following error: "TF14098: Access Denied: User needs ManageBranch permission(s) for $/ParentBranchName/ChildBranch". Basically it's complaining that the user doesn't have "Manage branch" permission on the branch that doesn't exist yet.

I can repoduce the issue. Grant permission on Root repository resolved it.
Below structure for example:
$/TFVC
-Main
-Test
If you want to branch from Main, then you need to grant the corresponding permission on both Main and $/TFVC
UPDATE:
Important
You cannot nest branches; therefore, you cannot convert any
folder to a branch if it either contains a branch or is contained by a
branch.
Source here : https://learn.microsoft.com/en-us/vsts/tfvc/branch-folders-files#convert-a-folder-to-a-branch
So, you can only create a branch as I mentioned above.
However if you really want to create a branch under the Main, then you can convert the Main branch to a folder first, then move the branch to Main.
Follow below steps:
Branch from Main as I mentioned in previous steps (For example,
CTest branch here).
Covert Main branch to a folder (Right click on Main branch -->
Branching and Merging --> Covert to Folder)
Move the created branch (CTest branch here) to Main (Right click
on CTest branch --> Move --> To Main folder )
Check in the changes

I ended up creating a folder, granting the "Manage branch" and "Merge" permissions on that folder. Then, as a matter of process, all new branches off of ParentBranch are created in that folder.

We can grant access to user/user group to "Create branch", that can be provided by following below steps
VSTS -> select Project -> Project Settings -> Repositories under Repos Title -> Security -> Search for User or Group and Click -> Right side pane opens for configuring User or Group selected -> Create branch -> Change "Not Set" to "Allow"

Related

Hide a branch in TFS

What I did, is that I have created a group with few members and assigned it to a branch.
When I login with a user from the restricted group, then I don't see any branches.
Then, added that group to the "Readers" group. Now I see all the branches in the project.
Is there a way to hide all other branches and show only the one that has that group?
Thank you
Git does not support read/contribute permissions on branches. TFVC - yes.
Consider using Forks.
In TFVC you can create a new folder in the root and move the restricted branches to it. Then set the Read permission to all root folders (except the new folder) to DENY for the restricted group.
In this case, the restricted group will see only the new folder and its content.
Thank you all for your answers!
I solved it by creating a new project with readonly permissions. So every time there's a change in the main project a task will be triggered in TFS to push the changes to the other project. That was the only option for me.

Why cant I branch a TFS project?

Its driving me crazy already, I have a folder converted into a branch, when I try to branch this one, the dialog suggests a name, which I accept, then after confirming that I really want to branch I get the nice error message:
TF10175: The MYPROJECT-branch team project does not exist.
Althoug the branch dialog clearly states: "The new branch will be created and commited as single operation"
Ok, so, when I branch to a existing but empty folder (converted to a branch according the MS doc) I get the opposite message:
The item $/MYPROJECT-TEST already exists.
So what is it now? It really drives me crazy. I just cant branch this damn project.
Please follow these steps to delete the workspace:
In "Team Explorer" select "Pending Changes"
Beside the "Check In" button click on "Actions" and select "Manage Workspaces…"
Select the Workspace and press "Remove"
Then follow these steps to branch a TFS project
when I branch to a existing but empty folder
We cannot specify an existing folder as a target. It will create a new folder based on the target path you entered, we should branch to a folder that does not exist. Then we can convert the folder to a branch via the button convert to branch.
Steps:
a.
b. Check in the new folder
c. Convert the folder test to branch:
Update1
Branch a TFVC project
Steps:
Select the TFVC project and convert the project to branch via the button Convert to branch.
Branch the TFVC project to an existing project repository folder.
Note: The target folder should not exist until the branch is completed. And we just can branch the project to another project repo folder.

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

Link a TFS Build Definition (CI) to a TFS Pull Request

I am reading the instructions from https://learn.microsoft.com/en-us/azure/devops/repos/git/pull-request-status?view=azure-devops#status-policy.
I have a TFS Build Definition which executes tests for every branch and reports success/failure.
I'd like to link the corresponding build to the Pull Request as well (and make require a green status to merge, if possible), similar to the screenshot below.
How can I do that, do I edit the repo Policies or in some other way? The link doesn't give much detail on how to do the actual linking.
Go to your repo -> branches -> select the branch that will be the target for your PullRequests -> Open the context menu left to the commit-id -> "Branch policies".
There you define your criteria for pull requests and can add a build under "Build validation".

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.

Resources