Skip to content

Instantly share code, notes, and snippets.

@bsantraigi
Created January 5, 2021 19:20
Show Gist options
  • Save bsantraigi/b6241e6c834250db5c2557b17ec5621f to your computer and use it in GitHub Desktop.
Save bsantraigi/b6241e6c834250db5c2557b17ec5621f to your computer and use it in GitHub Desktop.
Create backup of a Github Repo as a .bundle file. It will contain all remote branches and commit history.
# How to run
# chmod +x git_backup_repo.sh
# ./git_backup_repo.sh https://github.com/bsantraigi/MyRepo.git
REPO=$1
echo "Backup: $REPO"
DIR=$(grep -o -e "[^/]*.git$" <<< $REPO)
# DIR=$?
echo "Repo Cloned To: $DIR"
git clone --mirror $REPO
cd "$DIR"/
pwd
git bundle create "../$DIR.bundle" --all
cd ../
rm "$DIR" -rf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment