-
-
Save batmat/1004787 to your computer and use it in GitHub Desktop.
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/sh | |
# This post-commit hook is designed to serve as a central script for any repository you want to backup (via git bundle) | |
# based on the original idea of David Gageot https://gist.github.com/736547 | |
# Backup configuration | |
backupRoot="$HOME/Mes documents/My Dropbox/gitbackup/" | |
#howManyTime=--since=5.days | |
howManyTime=-10 | |
branchToBackup=master | |
# After some testing (under msysgit only for the moment), it seems like whereever you commit, the post-commit hook | |
# always gets executed from the repository root. | |
# So, let's just take the repository directory name for the bundle.Even when pwd | |
currentDirectory=`pwd` | |
backupFileName=`basename $currentDirectory` | |
git bundle create "$backupRoot$backupFileName" $howManyTime $branchToBackup | |
echo "Backup ok (time=$howManyTime,branch=$branchToBackup)" | |
# TODO/IDEAS | |
# * Externalize backup script, so that one can decide how&where he wants to backup | |
# * support many branches to backup if specified | |
# * Use default "git config" properties to get non-default values for this script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note : to enable it on any repository on your machine, put this script in the $GIT_HOME/share/git-core/templates/ and re-run git init in every repository you want to backup.