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:

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:


set -e -v

ORIGIN="$(realpath $1)"

rm -rf "$EXPORT"
git clone git:// "$EXPORT"

mkdir "$TARGET"
cd "$TARGET"
git init
git checkout HEAD

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

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