What are the differences between git clone --shared and --reference?

前端 未结 3 1917
谎友^
谎友^ 2020-12-13 12:59

After reading the documentation, I still don\'t really understand what the differences are between --shared and --reference . They seem

3条回答
  •  难免孤独
    2020-12-13 13:39

    Both options update .git/objects/info/alternates to point to the source repository, which could be dangerous hence the warning note is present on both options in documentation.

    The --shared option does not copy the objects into the clone. This is the main difference.

    The --reference uses an additional repository parameter. Using --reference still copies the objects into destination during the clone, however you are specifying objects be copied from an existing source when they are already available in the reference repository. This can reduce network time and IO from the source repository by passing the path to a repository on a faster/local device using --reference

    See for yourself

    Create a --shared clone and a --reference clone. Count the objects in each using git count-objects -v. You'll notice the shared clone has no objects, and the reference clone has the same number of objects as the source. Further, notice the size difference of each in your file system. If you were to move the source, and test git log in both shared and reference repositories, the log is unavailable in the shared clone, but works fine in the reference clone.

提交回复
热议问题