What is the best way to back up an entire git repository on external disk?

前端 未结 6 1009
情深已故
情深已故 2020-12-15 06:13

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

6条回答
  •  情深已故
    2020-12-15 06:41

    If you don't have any changes to back up in your work tree, you can use git clone --mirror to create a bare clone with all refs (branches, tags, absolutely everything) copied verbatim. You can then use git push --mirror to keep it up to date incrementally. This is what it's designed for.

    Copying the entire repo, including the work tree, works as well, but it's a bit of a pain to do incrementally, and obviously takes up more space.

提交回复
热议问题