Get repository from commit in jgit

I have a RevCommit (api) object. I want to get the Repository (api) object from it. My main goal is to get the origin url. So I planned to get Repository -> getConfig() -> -> load() -> getString().

How to get config object from RevCommit object?
Is this the correct way to get origin url from a commit?

  • Gitolite server-side setup for both http and ssh
  • Can I continue working while git pushes?
  • Can't add xCode 4.2 project to repository (and get it working)
  • Git reset not working
  • Rails 3 and Git: two applications, shared database
  • Good Git deployment using branches strategy with Heroku?
  • I tried googling but no success.

  • How is the git name determined when committing and pushing
  • How can I better handle commits polluting a “closed” branch in git?
  • How do I fetch/re-push a submodule in git?
  • GIT: Checkout to a specific folder
  • How do I merge a parent fork?
  • What are Jenkins best practices with building with Grunt and deploying with Capistrano?
  • One Solution collect form web for “Get repository from commit in jgit”

    The RevCommit does not reference the repository it was loaded from. You’ll have to track that in your application code.
    If you have a list of known repositories, you could lookup (repository.resolve( )) the commit. It feels a bit hacky though. And of course, you’ll end up with multiple hits if there are multiple repositories with the same content.

    Once you hold the repository in question you may use repository.getConfig().getString() to obtain the origins.

    If you believe that RevComit should reference the repository it belongs to, you may want to open an enhancement request to discuss that with the JGit team.

    Git Baby is a git and github fan, let's start git clone.