Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a Default branch on a TFS 2017 Hosted Repository

Tags:

git

tfs

Been banging my head around on this one. All I'm trying to do is set the a branch on the hosted TFS git repo to be default via the command line.

From what I can tell there's no obvious way to do this directly against the hosted repo, however in my case, since I'll end of scripting this, I have no objection in doing it locally and pushing it to the origin.

I tried things like:

git branch --set-upstream-to origin/master

to set master as the default branch within the hosted repo to no avail, so am unsure if I got the wrong end of the stick here.

I'm still a git toddler here so be easy on me if I missed something blindingly obvious!

like image 413
Rachel Ambler Avatar asked Feb 11 '17 19:02

Rachel Ambler


People also ask

How do I set a default TFS branch?

Under your project repo, select Branches. On the Branches page, select More options next to the new default branch you want, and choose Set as default branch. After you set the new default branch, you can delete the previous default if you want.

How do I change the default branch of a project?

Change the default branch name for a projectIn the left navigation menu, go to Settings > Repository. Expand Default branch, and select a new default branch. Optional. Select the Auto-close referenced issues on default branch checkbox to close issues when a merge request uses a closing pattern.

What is repository default branch?

The default branch is also the initial branch that Git checks out locally when someone clones the repository. Unless you specify a different branch, the default branch in a repository is the base branch for new pull requests and code commits. By default, GitHub names the default branch main in any new repository.


1 Answers

There isn't any way to set a Default branch on a TFS Hosted Repository with REST API or command line for now.

Check the Git command reference, the Git command line for setting a default branch in your Team Services/TFS repo is still on the web access (Select the settings icon on the web, then select the Version Control tab. Select your Git repository, then select the ... next to the branch name and choose Set as default branch).

like image 125
Cece Dong - MSFT Avatar answered Oct 02 '22 13:10

Cece Dong - MSFT