Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is git clone --mirror dangerous?

So I am going to migrate a bunch of repositories from bitbucket.org to a new on premise Bitbucket server instance.

What I can't decide on is whether to clone each repository as --bare or --mirror.

The scripted process seems pretty straight forward.

  • Get the repositories from bitbucket.org and write them to a file for use and to keep as a log. (already done and works)

  • Read the file, extract the repositories, repo slug(repo name) and clone them.(already working with --mirror)

  • For each cloned repo, run:

    • git gc --auto to cleanup repos
    • Create repo from slug on new on premise server
    • git remote set-url origin ssh://on_prem_server:7999/PROJ/REPO
    • git push --all origin
    • git push --tags origin

So I am not actually mirroring the bitbucket.org repos but migrating them. My understanding is that git clone --mirror gives a true copy of original. While git clone --bare does not and needs at least a fetch afterwards. This is why I initially thought using --mirror was best.

But now I am worried that there could be some danger in using a mirror.

So my questions are.

  • Are there any dangers using git clone --mirror I should be aware of?
  • Should I even use --mirror or is --bare good enough?
like image 604
tdh Avatar asked Feb 19 '26 15:02

tdh


1 Answers

--mirror just means to copy all refs "as-is" (instead of, for example, copying only branches and mapping them to remote tracking refs). Your use case is within its range of intended purposes.

(Just to clarify - --bare also maps refs directly rather than creating remote tracking refs form branches, but it doesn't copy all the refs like --mirror.)

like image 58
Mark Adelsberger Avatar answered Feb 21 '26 13:02

Mark Adelsberger