I have read Backing up Git Repositories, which recommends using git clone, as does everyone everywhere else. But I have some big stuff, and a slow connection at the other end. Would it be sufficient to clone it once, and then just perform a git fetch --all later on? It is important to get all branches. What would you recommend?



Using a single clone may be sufficient as a backup. But if you only have a single remote using the --all argument of git fetch won't accomplish anything, since that just tells git to fetch from all configured remotes.

If you want to ensure that you get all refs (including branches), you could run

git config --add remote.origin.fetch '+refs/*:refs/backup/*'

This would cause all refs from the remote to be fetched into a separate backup namespace of your refs hierarchy. These refs will not show up in the output of git branch even with the -a option.

Another option would be to first clone from your existing local repository to get all of the large objects into your backup clone without using the network (if your filesystem supports hard links even the disk space would be shared) then switch that over to fetching updates from the repository that you wish to backup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.