在外部磁盘上备份整个git存储库的最佳方式是什么? [英] What is the best way to back up an entire git repository on external disk?

查看:187
本文介绍了在外部磁盘上备份整个git存储库的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我希望能够将可能有多个分支的git存储库备份到外部硬盘驱动器上,然后在以后能够将其复制回本地计算机并像往常一样使用它?我试图简单地复制包含.git目录的工作目录文件夹,它工作。然而,我想知道这是否是最好的方式,或者以后有缺陷。 解决方案

使用常规复制整个工作副本文件系统复制命令正常工作。您还可以压缩/ tar备份。



如果您担心磁盘空间,您还可以查看 git bundle ,它可以生成较小的文件。



你也可以通过在外部磁盘上启动一个新的回购(git clone)来获得增量备份,然后每次取出更改(git pull)。在分布式系统(如git)中,备份和工作副本之间没有太大区别。


So I want to be able to back up a git repository that may have several branches onto an external hard drive and then be at a later time be able to copy it back onto my local machine and work with it as usual? I have tried simply copying the working directory folder containing the .git directory and it worked. However, I was wondering if this was the best way or if it had pitfalls later.

解决方案

Copying the entire working copy using regular file system copy commands works fine. You can also zip/tar the backup.

If you are worried about disk space, you can also look at "git bundle", which could produce smaller files.

You can also get incremental backups by just starting a new repo on the external disk (git clone) and then pull the changes every time (git pull). There is not much difference between a backup and a working copy in a distributed system like git.

这篇关于在外部磁盘上备份整个git存储库的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆