Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Sign in
O
OHR Support
  • Project
    • Project
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 97
    • Issues 97
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • Wiki
    • Wiki
  • image/svg+xml
    Discourse
    • Discourse
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Commits
  • Issue Boards
  • Projects
  • OHR Support
  • Wiki
  • Local git backups

Local git backups

Last edited by Alessandro Rubini Dec 11, 2013
Page history

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
Clone repository
  • Administrator guide
  • Documents
  • Folder structure example
  • Gitlab migration of ohwr faq
  • Home
  • Local git backups
  • News
  • Project structure guidelines
  • Project guidelines
  • Project re structure tips
  • Project review by ht volunteers
  • Repository use
  • Repository use2
  • Documents
    • Ohr logos
    • Ohwr new design visuals
More Pages

New Wiki Page

Tip: You can specify the full path for the new file. We will automatically create any missing directories.