How do I get started with Mercurial?
I've a newbie question about Mercurial.
Me and a friend just started to work t开发者_如何学Cogether to a project. We use BitBucket.
But how can we use mercurial and BitBucket in a good way? I mean, if I edit a file and my friend edit the same file? After every commit how can we update our local working repo?
You should be able to just pull remote changes into your local repository. See Pulling Changes into a Bitbucket Repository as a starting point for how you would actually do this.
Your local working repo is updated after each commit. If you want the (set of) changes in your local working repo to be reflected in the central or master repo, you should use hg push
When you want to get the updates of your friend from the master repo, you should use hg pull.
A probable course whould be:
before you work locally
hg pull
hg update
after you have made changes locally
hg commit
when you are sure you want others to see your changes
hg push
You are going to be able to each clone the repository, work locally, and merge back in. However, you should follow this course of action to have success:
Before starting anything new:
hg pull -u
That does a pull and an update operation in one command.
Do your work:
hg commit -m "Some commit message"
If you now want to push your changes to the remote repo, you need to check first if there are any incoming changes:
hg incoming
This will give you some information on incoming commits, but won't pull anything down.
hg pull
hg merge
This will pull the changes and merge your commits with the commits just pulled down. Since this is yet another change (the merge operation), you need another:
hg commit -m "Merged my changes with remote"
hg push
Lastly, the push will push the changes to the remote repo.
I do recommend reading the Hg Book, which will delve into more complex topics on specifying revisions to merge with (using hg merge -r12345
for example).
精彩评论