Is it safe to use a copied git repo?

前端 未结 3 1057
南笙
南笙 2021-02-11 16:32

If I make a copy of a tracked folder using rsync -a or cp -R, can I then use the copy as if it were a git clone, or will that cause all sorts of weird

3条回答
  •  时光取名叫无心
    2021-02-11 17:14

    It is safe.

    The difference in using "git clone" is that it automatically sets up the origin repository, so that you can easily use "git pull" and "git push" to synchronize the two repositories. Also "git clone" does not copy the logs, index and other configuration that is local to a repository. It only copies the version history of the repository (and even that can be stored at byte-level differently, because Git every now and then compresses its database when using "git gc").

    Those differences that you see in your example are because rsnc copied also the working directory index, logs and because the rsync-copy did not set up the remote origin. There are quite many configuration and log files that are local to a repository. But there is no danger in copying them directly, for example when restoring backups or moving the repository to another directory/harddrive/machine.

提交回复
热议问题