Skip to content

Instantly share code, notes, and snippets.

@FWDekker
Last active August 18, 2022 12:48
Show Gist options
  • Save FWDekker/97d7ef4d1955a84ab8622bea6d883d23 to your computer and use it in GitHub Desktop.
Save FWDekker/97d7ef4d1955a84ab8622bea6d883d23 to your computer and use it in GitHub Desktop.
How to archive a git repository (because I always forget how it works)
#!/bin/bash
# See also: https://git-scm.com/docs/git-bundle
# Create archive
## Bundle the entire repository into a file named `repo.bundle`
git bundle create repo.bundle --all
# Unpack archive
## Unbundle the file `repo.bundle` into the directory `my_repo`
git clone repo.bundle my_repo
## (Optional) Restore the remote to the `username/repository` repo on GitHub
git remote set-url origin [email protected]:username/repository.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment