libgit2 / libgit2/libgit2sharp

Not seeing any branches, can't create branch

Open
#1,658 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

I am running into the following error when i try to create a branch...

LibGit2Sharp.NotFoundException: revspec 'master' not found
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_annotated_commit_from_revspec(RepositoryHandle repo, String revspec)
   at LibGit2Sharp.Core.Proxy.git_branch_create_from_annotated(RepositoryHandle repo, String branch_name, String targetIdentifier, Boolean force)
   at LibGit2Sharp.BranchCollection.Add(String name, String committish, Boolean allowOverwrite)
   at LibGit2Sharp.BranchCollection.Add(String name, String committish)
   at LibGit2Sharp.RepositoryExtensions.CreateBranch(IRepository repository, String branchName)
   at EncompassSettingsExport.GitWriter..ctor(String PathToRepo, Signature Signature, CredentialsHandler credentialsHandler, String Branch, String SupplimentalPath, ILogger logger, Boolean purgeDirectory) in C:\Users\barnao\Downloads\EncompassSettingsExport2\EncompassSettingsExport\EncompassSettingsExport\GitWriter.cs:line 52
   at EncompassSettingsExport.Program.<Run>d__1.MoveNext() in C:\Users\barnao\Downloads\EncompassSettingsExport2\EncompassSettingsExport\EncompassSettingsExport\Program.cs:line 71
Finished! Press any key to exit...

The line of code that produces this error is

brnch = repo.CreateBranch(Branch)

Where Branch is just a string like "test-brnch" and repo is a Repository object i've already created.

I am checking to make sure i can see my repo here (it is a private non-local repo)

Repository.IsValid(PathToRepo)

and this returns true.

I create my repo here...

repo = new Repository(PathToRepo);

However i've noticed that when i call

repo.Branches.Count();

This return 0 even though i do have a few branches in my repo

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with EncompassSettingsExport.GitWriter.cs line 52 and Program.cs line 71, then inspect the Repository setup and the repo.Branches.Count() result. Reproduce the branch-creation attempt against the described private repository and verify whether existing branches are enumerated and CreateBranch succeeds; document the relevant failure or fix with a regression test if the project provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.