CodePack
A CLI tool to create local backups for multiple git repositories
Instructions
name
will be the name of the project and the directory containing the code after packing
path
will be the path that will be created in the archive
url
the url to the target git repository
repos:
- name: grype
path: tools
url: "https://github.com/anchore/grype.git"
- name: semgrep
path: tools
url: "https://github.com/returntocorp/semgrep.git"
- name: cobra
path: development
url: "https://github.com/spf13/cobra.git"
Usage of codepack:
-config string
Configuration file (default "codepack.yaml")
-out string
Output filename for the tarball (default "2023-06-14-git-backup.tar.gz")
codepack -config mycodepack.yaml -out "my-backups.tar.gz"
this will produce a gzipped tarball that can be extracted with tar if necessary
tar xf 2023-06-14-backup.tar.gz
The resulting directory structure after extraction for the example would be
codepack
|_ tools
|_ grype
|_ semgrep
|_ deveopment
|_ cobra
these are bare, mirrored repositories which can be used with worktrees or cloned to another directory
mkdir somedir
git clone --all file://<full path to codepath>/tools/grype somedir/grype
cd somedir/grype
git branch
git status
Using worktrees:
cd codepack/tools/grype
git worktree add main main
cd main
git status
Using worktrees will create a folder named main
with the main
branch checkout in that directory