Search code examples
gitgit-clonegit-pull

What is the difference between git clone --mirror and pull


There really is no difference between clone and pull is my understanding. Or in other words git clone -- bare and git pull does the same. But since git clone --mirror updates the local references would it be different from pull ?


EDIT: I mistakenly assumed git clone default is --bare. But --bare will be setup without working directory.


Solution

  • git clone creates a new repository. You had no repository before, and now you have one.

    git pull does operations in an existing repository.

    That seems like a really big difference!

    Other than that, what git pull does is:

    • run git fetch, then
    • run a second Git command.

    Since a --mirror clone is a --bare clone and therefore has no work-tree, the second command that git pull would run will fail, no matter whether you choose merge or rebase.

    What git fetch does is documented. With a mirror clone, the default refspec is +refs/*:refs/*, so that all references are replaced with those obtained from the other Git.