Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Getting default branch of remote repository

Thanks a lot Matthias. Will try and update you


On Mar 14, 2017, at 9:48 PM, Matthias Sohn <matthias.sohn@xxxxxxxxx> wrote:

sorry, the last line should read AnyObjectId = head.getObjectId()

On Tue, Mar 14, 2017 at 8:35 PM, Matthias Sohn <matthias.sohn@xxxxxxxxx> wrote:

using JGit try something like

Ref head = Git.lsRemoteRepository().setRemote("https://git.eclipse.org/r/jgit/jgit").callAsMap().get("HEAD");
if (head != null) {
   if(head.isSymbolic) {
      Ref b = head.getTarget();
   } else {
      AnyObjectId id = ObjectId.fromString(head);
   }
}


On Tue, Mar 14, 2017 at 6:23 PM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
Do an ls-remote, check the capabilities for "HEAD=<branch>".

Maybe Git could learn to just obtain said HEAD in a "clone --single-branch".

On Tue, Mar 14, 2017 at 5:50 AM, Alaa Nassef <alan.125@xxxxxxxxx> wrote:
> Hello All,
>
> What I need to do is to find out the default branch of of a remote repository, i.e. find out the branch where HEAD symbolic ref points to. I need to do this without cloning the whole repo, so that I can fetch only this branch.
>
> Thanks & Best Regards
> Alaa Nassef
> _______________________________________________
> jgit-dev mailing list
> jgit-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jgit-dev
_______________________________________________
jgit-dev mailing list
jgit-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jgit-dev




Back to the top