In a previous post, I explained how SNAKES moved to GitHub. It now has another address, on a GitLab instance freshly installed at IBISC lab: https://forge.ibisc.univ-evry.fr/fpom/snakes.

I'll maintain both synchronised, so that visitors have the choice of their preferred interface.

On my way to host SNAKES and change from Mercurial to Git, I discover useful new things, nothing new for seasoned Git users but let me share them anyway.

Git trick #1: simultaneously push to several repositories

By the way, I discovered a useful trick to push onto two servers with just one git push (original post on Stack Overflow). One just need to use several git remote in a row:

$ git remote set-url --add --push origin git://one/repo.git
$ git remote set-url --add --push origin git://another/repo.git

Then every push goes onto both remote repositories.

Git trick #2: informative bash prompt in Git repositories

Just install and setup Bash Git prompt, this is incredibly useful! I configured it with GIT_PROMPT_ONLY_IN_REPO=1 so that it shows up only within repositories and I keep my usual prompt everywhere else.

Git trick #3: convert a Mercurial repository to git

Here is my script hg2git that is so simple that no comment seems necessary:

#!/bin/sh

set -e -v

ORIGIN="$(realpath $1)"
TARGET="$ORIGIN.git"
EXPORT="/tmp/hg2git"

rm -rf "$EXPORT"
git clone git://repo.or.cz/fast-export.git "$EXPORT"

mkdir "$TARGET"
cd "$TARGET"
git init
$EXPORT/hg-fast-export.sh -r "$ORIGIN"
git checkout HEAD

if test -f .hgignore
then
    git mv .hgignore .gitignore
    sed -i -e '/^syntax:/d' -e '/^$/d' .gitignore
    git add .gitignore
    git commit -m "migrated .hgignore"
fi

mv "$ORIGIN" "$ORIGIN.hg"
mv "$TARGET" "$ORIGIN"
rm -rf "$EXPORT"