Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:29:42+00:00 2026-06-05T18:29:42+00:00

I’m using libgit2sharp and I’d like to get a Commit object representing something like

  • 0

I’m using libgit2sharp and I’d like to get a Commit object representing something like HEAD~10. I tried repo.Lookup("HEAD~10"), but that doesn’t work:

LibGit2Sharp.LibGit2Exception: An error was raised by libgit2. Class = GITERR_REFERENCE (-1).
The given reference name is not valid
  at LibGit2Sharp.Core.Ensure.Success(Int32 result, Boolean allowPositiveResult)
  at LibGit2Sharp.ReferenceCollection.Resolve[T](String name)
  at LibGit2Sharp.Repository.Lookup(String shaOrReferenceName, GitObjectType type, LookUpOptions lookUpOptions)
  at LibGit2Sharp.Repository.Lookup(String shaOrReferenceName, GitObjectType type)
  at libgit_tmp.Program.Main(String[] args)

I realize I could do the same by something like the following code, but I’d still prefer it if I could specify the reference this way. Is there some way to do it? If not, is it a limitation of libgit2sharp or of libgit2?

var commit = repo.Head.Tip;
for (int i = 0; i < 10; i++)
    commit = commit.Parents.First();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:29:43+00:00Added an answer on June 5, 2026 at 6:29 pm

    Unfortunately, LibGit2Sharp isn’t able to accept parameters following the rev-parse revision-specification syntax.

    The proposed workaround is currently the best possible implementation. It’s fully compliant with the documentation which states

    A suffix ~<n> to a revision parameter means the commit object that is the <n>th generation ancestor of the named commit object, following only the first parents.

    However, a feature has been recently merged in the development branch of libgit2 which may cover “retrieving parent references” need and beyond.

    A nice API is now available and makes possible to retrieve a concrete git object from a revparse textual specification. In order to get a quick peek at its usage, the tests are available here.

    Binding this API and making it widely available to LibGit2Sharp is yet to be done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.