Nudge — A Gentler Version of Push

posted by Steve Losh on September 28, 2009

One thing that seems to confuse a lot of git users that try out Mercurial is the fact that by default Mercurial will try to push all changesets in the repository when you run hg push, while git only pushes the current branch.

If you prefer git’s behavior (maybe you frequently work on branches that you never end up pushing) it’s simple to add an alias that comes close.

Mercurial lets you use . as a shortcut to specify “the parent revision of the working directory.” Using this with push means you can run hg push --rev . to push only the working directory’s parent revision (and its ancestors). That way you don’t have to worry about pushing any of the other branches you’re not working on.

To add an alias for this, edit your ~/.hgrc file to contain:

[alias]
nudge = push --rev .

Now you can run hg nudge to just push what you’re working on at the moment.

Add an hg nudge alias to push only the working directory’s parent(s).