Create a new Mercurial repository on Mac

Every months or so, I create a new repository for the development project I work on. But I always tend to forget how to setup the repository, so here's a quick start quide which I found very helpful and I hope you will too.

1. First of all, we need to create a username file: .hgrc

Include the following text:

[ui] username = Your Name <yourname@domain.com>

Save it under you home folder eg:

Guillaumes-MacBook-Pro: guillaumepiot$ cat ~/.hgrc 
[ui] username = Your Name <yourname@domain.com>

This command should return the content of the file.

2. Go to your project folder

$ cd /my/folder

Start the repo:

$ hg init

* You can create a .hgignore file inside the .hg folder (make sure your hidden files are showing). This file will ignore a list of extension for example:

syntax: glob *.pyc *.txt

This will ignore Python compiled files and txt files.

3. Add project files to the repo:

$ hg add

or

$ hg addremove
(if you set up your ignore file after the init)

4. Commit your work:

$ hg commit -m 'Explain here the reason of this commit'

This will create a new commit, the message explained what has been added or modified.

5. Push you work to the repository:

I advice to create a file with default settings for convenience, which will stop you from entering the repo URL each time.

In the .hg folder, create a file called hgrc and put the following:

[paths] default-push = ssh://hg@codebasehq.com/vivaaspire/viva-website/hotel_innovation_network.hg

Then push:

$ hg push

It should be all set now.

This is a very basic startup guide, there's many things you can do an option but that I recommend you check the Mercurial website: http://mercurial.selenic.com/

< / >