When we’re first starting our work, we have to decide if this is a separate area of work we’re working on, or is this part of an existing line of work. If it’s existing, we can work off of that branch. If it’s new, we’ll start a new branch.
Our workflow then is:
hg branch MyNewFeature
hg commit -m "committing my changes"
hg commit -m "more changes"
At this point, we want to push our work up to the remote server. But before pushing the changes (ignore this if it is a new branch you haven't pushed before), we need to check if there are any incoming change to this branch. We can check this with:
hg incoming -b .
If there are any incoming changesets on our branch, we need to do a pull and rebase our changes to the top of the list of changes.
hg pull -b . --rebase
Once this is done or if there are no incoming changesets, we can proceed with the Push.
We only ever want to push our current work, not everything we’ve ever done. I really never push my entire repository, but my current line of work. The reasoning is that pushing the entire repository assumes I’m integrating multiple lines of work. But I only want to integrate my current line of work, and I only want to work in one line at a time.
If this is the first time I’m pushing this branch:
hg push -b . --new-branch
If I've already pushed this branch:
hg push -b .
The “-b .” command means just push the current branch, and not anything else.
To change between the working branches:
hg update myBranchName