Hi! Feel free to close & ignore this, but this was one of the things I found while looking for how to archive a github repo, so I thought I'd share what I came up with. My main extra requirement was archiving all branches, not just master.
#!/usr/bin/env bash
if [ ! "$1" -o ! "$2" ]; then
echo 'archive.sh <repo_name> <repo_remote_path>'
exit 1
fi
repo_name=$1
remote_path=$2
# add all branches
git remote add $repo_name $remote_path
git fetch $repo_name
git push origin refs/remotes/$repo_name/*:refs/heads/$repo_name-*
git fetch origin
# copy the archivee's master branch into a folder of our master branch
git fetch $repo_name master
git read-tree --prefix=$repo_name -u $repo_name/master
git commit -m "Add $repo_name snapshot to master"
git push origin master
This pushes all branches of the old repository to prefixed branches in the archive repo, as well as snapshotting master in a subfolder on the archive's master. The snapshot makes for easy browsing, while the branches provide a more accurate replica.
Hi! Feel free to close & ignore this, but this was one of the things I found while looking for how to archive a github repo, so I thought I'd share what I came up with. My main extra requirement was archiving all branches, not just
master
.This pushes all branches of the old repository to prefixed branches in the archive repo, as well as snapshotting
master
in a subfolder on the archive's master. The snapshot makes for easy browsing, while the branches provide a more accurate replica.