DEV Community

Anatoli Babenia
Anatoli Babenia

Posted on

Script to move from Bitbucket Hg to Git

Bitbucket was born as a Mercurial hosting, and now the service is being stripped of Hg by Atlassian. Atlassian warned that it will just remove the repos. It doesn't seem to care to archive them. That's why you are here.

To use the script, you will need to edit REMOTE variable to point to your remote Mercurial repository. When your run the script, it will download hg-git, clone and convert your repo, and drop you into the shell in newly converted git repository, which you can immediately git push to GitHub, GitLab or another hosting of your choice.

#!/bin/bash

set -x

REMOTE=ssh://hg@bitbucket.org/rainforce/pyrobot
NAME="$(basename $REMOTE)"

mkdir /tmp/"$NAME"
cd /tmp/"$NAME"
hg clone https://foss.heptapod.net/mercurial/hg-git
hg clone "$REMOTE"

mkdir "$NAME"-git
(cd "$NAME"-git &&
 git init)

(cd "$NAME" &&
 hg bookmarks hg &&
 hg --config extensions.hggit=../hg-git/hggit push ../"$NAME"-git)

(cd "$NAME"-git &&
 git checkout -b master hg &&
 $SHELL)    
Enter fullscreen mode Exit fullscreen mode

Mercurial is still awesome.

DevCycle image

Ship Faster, Stay Flexible.

DevCycle is the first feature flag platform with OpenFeature built-in to every open source SDK, designed to help developers ship faster while avoiding vendor-lock in.

Start shipping

Top comments (0)

Tiger Data image

🐯 🚀 Timescale is now TigerData: Building the Modern PostgreSQL for the Analytical and Agentic Era

We’ve quietly evolved from a time-series database into the modern PostgreSQL for today’s and tomorrow’s computing, built for performance, scale, and the agentic future.

So we’re changing our name: from Timescale to TigerData. Not to change who we are, but to reflect who we’ve become. TigerData is bold, fast, and built to power the next era of software.

Read more

👋 Kindness is contagious

Explore this compelling article, highly praised by the collaborative DEV Community. All developers, whether just starting out or already experienced, are invited to share insights and grow our collective expertise.

A quick “thank you” can lift someone’s spirits—drop your kudos in the comments!

On DEV, sharing experiences sparks innovation and strengthens our connections. If this post resonated with you, a brief note of appreciation goes a long way.

Get Started