Let's call our project demo. It sits in a folder demo on my local drive. All I want is to enable Mercurial and start syncing it with Bitbucket repository. To accomplish just that we need just few steps.
- Install Mercurial. Make sure Mercurial command hg is in your classpath.
- Go to your project folder demo and run from command line:
hg init
You initiated brand new Mercurial repository that will contain files from demo project in a couple of steps. - Create .hgignore file in demo folder to prevent Mercurial from adding files that don't belong to source control: build (or target with maven) folder, compiled classes, etc. For example see here.
- From command line in demo folder run:
hg add
You added all your files to Mercurial repository with exception of those identified by .hgignore. - From command line in demo folder run:
hg commit
This is actual commit - without it those files that you added in the step before are just placeholders. - Register on Bitbucket (Suppose you registered using name myusername).
- Create new repository and call it demo. This is your hosted Mercurial repository that you can access with url https://bitbucket.org/myusername/demo. Check with Bitbucket for exact URL.
- Update your remote repository (which is empty) with your existing demo files, from command line in demo folder run:
hg push https://bitbucket.org/myusername/demo - Save a push URL so that you don't need to enter it each time when you use hg push or hg outgoing commands. Locate hgrc file in demo/.hg folder (create if it doesn't exist) and add:
[paths] default-push = https://myusername@bitbucket.org/myusername/demo
We are done with initializing new Mercurial repository. If you don't want any hosting then you are done - your project is a Mercurial repository now. I recommend to read this to get started with Mercurial.
You've done it! Your lonely project just became both hosted (source code) and backed by enterprise-strength DVCS.
1 comment:
Hi,
default = u/r/l
worked for me (-push didn't).
Post a Comment