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?

  • How do I configure Eclipse to use an existing git repository with existing source code?
  • Execute Gulp tasks and watches remotely
  • mysterious vanishing branches in git
  • How does git-rebase recognize “aliased” commits?
  • Can't merge branches Xcode Sourcecontrol
  • How to change a local repository name on GitHub for Windows
  • I tried googling but no success.

  • Efficientily forward porting changes of core theme: Git Three Way Merge with Core Changes?
  • Avoid repository creation on typo
  • git push question
  • Git-Repo searching for String in all committed files (unknown branch and commit)
  • Error in running 'git apply'
  • What's the best way to transfer a GIT-SVN debug->feature branch to trunk?
  • 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( commit.name() )) 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.