Created
August 5, 2013 18:32
-
-
Save wallyatkins/6158249 to your computer and use it in GitHub Desktop.
This is a quick script that will archive all of your git repositories managed with gitolite into zip files. This script "works for me" to just archive the master branch of the repositories. There are probably some more elegant ways to do these operations or the gitolite configuration might vary from how I do mine ... feel free to make suggestion…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # This script reads a gitolite.conf file to gather a list of all the repositories. | |
| # The script then iterates through all of the repositories names. It then clones only | |
| # the master branch of each repository (git version >= 1.7.10) and then archives the | |
| # repository into a zip file. | |
| if [[ "$1" = "" || "$2" = "" || "$3" = "" ]]; then | |
| echo "Usage: $0 <full path to gitolite.conf> <full path to archive dir> <git clone prefix>" 1>&2 | |
| exit 1 | |
| fi | |
| cd $2 | |
| for arg in `cat $1 | grep repo` | |
| do | |
| if [ ${arg} != "repo" ]; then | |
| echo "Archiving Git repo: ${arg}" | |
| # clone just the master branch (requires git version >= 1.7.10) | |
| # git clone -b master --single-branch "$3:${arg}.git" | |
| # clone the git repo | |
| git clone "$3${arg}.git" | |
| # enter into the git repo directory | |
| cd "${arg}" | |
| echo `pwd` | |
| # archive the repo | |
| git archive --format zip --output "$2/${arg}.zip" master | |
| # exit the repo directory and then delete it | |
| cd .. | |
| rm -rf "${arg}" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment