libgit2 / libgit2/libgit2sharp

Not seeing any branches, can't create branch

未关闭
#1,658 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
3.5k
派生
925
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 EncompassSettingsExport.GitWriter.cs 第 52 行和 Program.cs 第 71 行开始,然后检查 Repository 的设置以及 repo.Branches.Count() 的结果。针对所述的私有仓库重现创建分支的尝试,并验证是否会枚举现有分支以及 CreateBranch 是否成功;如果项目提供回归测试,请使用回归测试记录相关的失败或修复。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, git
领域
devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。