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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With