Phoenix
Phoenix

Reputation: 913

Visual Studio Online - The version descriptor <BranchName> could not be resolved

I am working on a project with visual studio online and git.

I tried accessing the TFS Online web site and openning the source code of the project I am working on and I found this error popping up absolutely everywhere:

TF401175:The version descriptor Branch could not be resolved to a version in the repository ProjectName

I can't access the branches, commits, source code or absolutely anything. The other team members don't have the problem, and it seems to be tied to my account, seeing as I tried openning it on another device with my account and still failed.

All operations from visual studio work fine. I can commit, pull, push, etc. I only can't access the Web Panel. Tried googling for the error but all I found was the bug reported on the MS site, which was closed and said that the problem is fixed. Doesn't seem fixed to me.

Upvotes: 12

Views: 15180

Answers (5)

Sellerman
Sellerman

Reputation: 41

I've had this issue for a long time. We migrated code into a new repo and then deleted the primary branch. Every time we made a pull request we got this error. I finally figured out how to solve it:

  1. Go to your Branches page.
  2. Pick any branch other than your current default branch and click on the 'More Options' dots.
  3. Set this branch as the 'Compare' branch.
  4. Pick the branch you want to be the default PR branch and click on the 'More Options' dots.
  5. Set this branch as the 'Compare' branch.

This link clued me in on this solution: https://developercommunity.visualstudio.com/t/the-default-branch-wont-be-default-item-of-target/200210

Upvotes: 4

Artie Leech
Artie Leech

Reputation: 387

In our team's case, we got this error when we tried to create Pull Requests in the Azure Devops UI.

We think we got this error because our branch names typically have forward slash characters in the name, e.g.

peter/bugfix/BF123-fix-surname-width-issue

When attempting to create a PR for a branch named like that, the error would include each / having been converted to ASCII, so:

peter%2Fbugfix%2FBF123-fix-surname-width-issue

Our fix was to select the branch from the branch selector on the same page as the error message, (which was correctly shown with the / characters rather than ASCII) and continue creating our PR.

Upvotes: 0

unsafePtr
unsafePtr

Reputation: 1773

In my case I tried to get file contents and got eventually the same error.

TF401174: The item 'item' could not be found in the repository 'repository' at the version specified by 'Branch:' (resolved to commit 'commit')'

I was trying to make if from the the VisualStudioOnline libs (Microsoft.VisualStudio.Services.Client, Microsoft.TeamFoundationServer.Client)

VssBasicCredential credintials = new VssBasicCredential(String.Empty, "YOUR SECRET CODE HERE");
VssConnection connection = new VssConnection(new Uri("https://yourserverurl.visualstudio.com/"), credintials);
GitHttpClient client = connection.GetClient<GitHttpClient>();

List<GitRepository> repositories = await client.GetRepositoriesAsync(true); // or use GetRepositoryAsync()
var repo = repositories.FirstOrDefault(r => r.Name == "Some.Repo.Name");

GitVersionDescriptor descriptor = new GitVersionDescriptor()
{
    VersionType = GitVersionType.Branch,
    Version = "develop",
    VersionOptions = GitVersionOptions.None
};

List<GitItem> items = await client.GetItemsAsync(repo.Id, scopePath: "/", recursionLevel: VersionControlRecursionType.Full, versionDescriptor: descriptor);

Then if you will try directly to get contents of an item client.GetItemTextAsync(repo.Id, item.Path) you will receive such kind of error in case when the branch isn't default. Just provide GitVersionDescriptior again.

GitVersionDescriptor commitDescriptior = new GitVersionDescriptor()
{
    VersionType = GitVersionType.Commit,
    Version = item.CommitId,
    VersionOptions = GitVersionOptions.None
};

Stream stream = await client.GetItemTextAsync(repo.Id, item.Path, download: true, versionDescriptor: commitDescriptior)

Upvotes: 0

Spyder
Spyder

Reputation: 4052

I got the same error.
In my case my local branch had not yet been synced to the server, so in my web browser the Pull-Request was on the server (vsts) but my branch was not.
To fix it: I did a Sync in VS, pushed my local branch, then it worked: I refreshed the Pull Request in the browser and then the error disappeared.

Upvotes: 3

DaveShaw
DaveShaw

Reputation: 52798

Your default branch has been deleted.

You need to change your default branch to one that exists. Try using the branch selector, it that's not available, try appending #path=%2F&version=GBmaster&_a=contents to the end of the default "Code" URL.

Upvotes: 10

Related Questions