gitgitlabgit-fetchgit-ls-remote

Why doesn't git ls-remote list all the remote refs?


I have a remote repo (origin) whose refs directory contains, in addition to the usual heads, tags, and remotes subdirectories, also keep-around and merge-requests. These are special sets of refs that are managed by Gitlab for its internal housekeeping.

When I use git ls-remote to interrogate this repo, the command lists the merge-requests refs but not the keep-around requests:

$ git ls-remote
5ef8f113ba35360de0dfc015601bb832bacb5505        HEAD
... lots of refs/heads/...
... lots of refs/merge-requests/...
... lots of refs/tags...

Similarly, I can fetch merge-requests refs, for example with

$ git fetch origin refs/merge-requests/999/head
From git.company.com:Company/company
 * branch                    refs/merge-requests/999/head -> FETCH_HEAD

but when I ask for a keep-around ref, the remote repo claims it doesn't exist, even though I know it does:

$ git fetch origin  refs/keep-around/291ad6a6bebf067377700d430ac130d758ed52e9
fatal: couldn't find remote ref refs/keep-around/291ad6a6bebf067377700d430ac130d758ed52e9
fatal: The remote end hung up unexpectedly

I don't see anything in the remote repo's config that seems to relate to this. What's causing the different behavior?


Addendum: Meredith Howard suggests that this may be a feature of Gitlab; there is a special Gitlab config that tells it specifically to hide the refs in refs/keep-around. See this support request from someone with a similar question.


Addendum: It has been suggested that this is a duplicate of Git fetch a specific commit by hash . I am not trying to fetch a specific commit by hash. I want to know why the remote repo is omitting certain refs from its listing.


Solution

  • Every Git web-hosting site can, through whatever configuration mechanisms that site uses (most likely a --system config file), hide whatever references it likes. Git itself has a general-purpose mechanism for this: transfer.hideRefs. See the git config documentation for details. If you run your own servers, you can set them up this way.