Last Updated: February 25, 2016
·
693
· jacobfike

Make a full copy of a git repo

This is a pretty common problem with git, and there are various answers, but most of them involve either creating and running a bash script, or manually checking out each branch. Here is a way to do this purely through simple git commands:

mkdir repo
cd repo
git clone --bare path/to/repo.git .git
git config unset core.bare
git reset --hard

At this point you have a complete copy of the remote repo with all of it's branches (verify with git branch). You can use --mirror instead of --bare if your remote repo has remotes of its own.