Local GIT Backups
I (Alessandro) strongly suggest to keep a backup of your
development on your personal machines, so any rebase made by
others won't lose your commits (such rebases are errors, for
sure, but they still may happen).
You'll notice that most of my OHWR development branches have a date
inside, of the form YYMMDD -- I plan to stop coding before
2100 :) . When I rebase, I push a new branch with a different
date, and delete the previous one(s) when the time is ripe. This
allows me to have a backup of every branch: I have a local
repository for every project, that makes a "git fetch work" every
hour, under cron.
To setup a similar mechanism, you can just do this
cd /path/to/git-backup
mkdir $project
cd $project
git init --bare
git remote add work $HOME/work/$project
If every directory inside /path/to/git-backup
includes a remote
called "work" or some other magic word, you can just fetch them all.
I personally have a few magic names that are fetched by cron
.
This is an extract of the script I run hourly from my backup place:
findrepos () {
# non -bare
find . -maxdepth 3 -name .git -print | xargs -n 1 dirname
# bare
find . -maxdepth 3 -name objects -print | xargs -n 1 dirname | \
grep -v '/.git$'
}
REPOS=$(findrepos | sed 's/^..//')
REMOTES="work pub"
D=$(/bin/pwd)
for repo in $REPOS; do
if tty > /dev/null; then echo "Repo $repo"; fi
cd $D/$repo
for remote in $REMOTES; do
if git remote | grep -q "^$remote\$" ; then
git fetch $remote
git fetch --tags $remote
fi
done
done
using a