Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 831
racl101 Avatar asked Dec 07 '10 02:12

racl101


People also ask

How do I backup a GitHub repository?

The correct answer is to do a: git clone --mirror [email protected]/your-repo. git This will copy your entire repository, notes, branches, tracking, etc.

How do I save a git repository locally?

Determine the appropriate repository. Fork the repository to your GitHub account. Choose a local folder for the cloned files. Clone the repository to your local machine.

Do I need to backup GitHub?

Github is not a backup service and companies that rely on the hosted product should have a backup solution in place. Github, like most SaaS platforms, follows the Shared Responsibility Model in which responsibilities are divided between the platform and the user.


1 Answers

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.

like image 159
Thilo Avatar answered Oct 12 '22 11:10

Thilo