##// END OF EJS Templates
javascript: add default value for js generate ini option
javascript: add default value for js generate ini option

File last commit:

r1:854a839a default
r264:1372c5bb default
Show More
rebase-commits.rst
118 lines | 4.0 KiB | text/x-rst | RstLexer

How to Rebase in |hg|

To rebase in |hg| you will need the rebase extensions enabled in your :file:`~/.hgrc` file. Use the following example, or for more detailed information see the :ref:`config-hgrc` section.

[extensions]
rebase =

Rebasing in |hg|

Occasionally you may have to rebase commits if you have created a new head on your fork. In short, rebasing mean taking one commit and moving a commit, or set of commits, from a different head on top of it. To do this, use the following example:

  1. Check your on the right branch, and move to the correct one if needed.
# Display which branch you are on
$ hg branch
default

# Move to the stable branch
$ hg update stable
  1. Look at your graphlog, and decide what commits need to be rebased. In this case, I want to rebase 1206 and 1207 on top of 1226. Note how these are already in a public state as I have already pushed to my fork.
  1. To do this use the following example.
    • Draft the commits back to the source revision.
    • -s is the source, essentially what you are rebasing.
    • -d is the destination, which is where you are putting it.

Rebasing the source commit will automatically rebase its descendants. In this example I am using --force to draft commits already pushed to my fork. Doing this is not best practices on a main |repo|.

# Put the commits into draft status
# This will draft all subsequent commits on the relevant branch
hg phase --draft --force -r 1206

# Rebase 1206 on top of 1226
$ hg rebase -s 1206 -d 1226
saved backup bundle to /repo-fork/.hg/strip-backup/39562e195e34-backup.hg
  1. Once you have rebased the commits, check them on the graphlog
  1. Once you have finished your rebase, if the the original |repo| history on the server is different you have two options:
    • Push the specific revisions using hg push -r <revision>, or push all with force using hg push --force which will create a new head.
    • Strip your commits on the server back to a previous revision, and then push the new history. To strip commits on the server, see the strip information in the :ref:`api` documentation.

Important

As with all examples, this one is rather straight forward but rebasing can become a complicated affair if you need to fix merges and conflicts during the rebase. For more detailed rebasing information, see the Mercurial Rebase page which has more detailed instructions for various scenarios.