'refusing to create funny ref' error when pushing

0

I have a code commit repository, that I am using as a mirror backup for a self hosted gitlab repository. When I try to git push --mirror to the code commit repository, I am getting the error

remote: error: refusing to create funny ref 'refs/keep-around/12b32218d03ff85ec051a3c0d9bd7272b50b5741' remotely.

If I try to delete the above ref, then I get the error for another ref under refs/keep-around. Google bard suggested that AWS does not support refs/keep-around, but that is incorrect because I tried manually pushing some of the refs under refs/keep-around and the error is thrown only for some of the refs.

I checked git source for references to funny ref, and it is thrown when the reference name contains invalid characters. And the above ref name is valid, as per the checks.

https://github.com/git/git/blob/dadc8e6dacb629f46aee39bde90b6f09b73722eb/builtin/receive-pack.c#LL1466C37-L1466C57 https://github.com/git/git/blob/dadc8e6dacb629f46aee39bde90b6f09b73722eb/refs.c#L143

 * Try to read one refname component from the front of refname.
 * Return the length of the component found, or -1 if the component is
 * not legal.  It is legal if it is something reasonable to have under
 * ".git/refs/"; We do not like it if:
 *
 * - it begins with ".", or
 * - it has double dots "..", or
 * - it has ASCII control characters, or
 * - it has ":", "?", "[", "\", "^", "~", SP, or TAB anywhere, or
 * - it has "*" anywhere unless REFNAME_REFSPEC_PATTERN is set, or
 * - it ends with a "/", or
 * - it ends with ".lock", or
 * - it contains a "@{" portion

Why is it still failing?

asked a year ago328 views
1 Answer
3

I have added these ref links for your review

https://outlandish.com/blog/how-to-purge-sensitive-data-from-gitlab/ https://gitlab.com/gitlab-org/gitlab/-/issues/4894

  • The error message "refusing to create funny ref" typically indicates that Git has encountered a reference name that it considers invalid or unusual.
  • refs/keep-around is one of them and is used internally by GitLab for housekeeping purposes, specifically for preventing certain objects from being garbage collected.
  • using --mirror option with git push can overwrite refs on the remote repository that don't exist in your local repository
  • You could try pushing to CodeCommit without the 'refs/keep-around' references. This can be achieved by using the 'git push' command with an explicit refspec that only includes the refs you want to push
profile picture
EXPERT
answered a year ago
  • Thank you for your response.

    The error message "refusing to create funny ref" typically indicates that Git has encountered a reference name that it considers invalid or unusual.

    The ref name that is refused, does not contain any unusual characters. I have verified it by passing the ref name to the check_refname_component C function.

    refs/keep-around is one of them and is used internally by GitLab for housekeeping purposes, specifically for preventing certain objects from being garbage collected.

    Not every ref under refs/keep-around is failing. So refs/keep-around prefix itself is not the issue.

    using --mirror option with git push can overwrite refs on the remote repository that don't exist in your local repository

    This is meant as a additional backup copy, so I want it to be an exact copy. So overwriting is the intended behaviour here.

    You could try pushing to CodeCommit without the 'refs/keep-around' references. This can be achieved by using the 'git push' command with an explicit refspec that only includes the refs you want to push

    I don't mind losing the refs under refs/keep-around, but I don't want it to miss any other ref. Can I do this with a negative refspec, that only exclude everything under refs/keep-around?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions