Search code examples
version-controlmercurialbitbucket

Switch from clone to new fork preserving changes


I cloned a remote repository from BitBucket, made changes (without pushing/committing anything). I've decided that it would be better to modify a fork than the original. I've just created a fork on BitBucket --- but how do I change my local version to work with the new fork instead of the original source?


Solution

  • You don't need to change anything you just push and pull from your fork instead of the original.

    For example if the original is:

    https://bitbucket.org/SomeProject/SomeProject

    and your fork is:

    https://bitbucket.org/MyUserName/SomeProject

    and you did:

    hg clone https://bitbucket.org/SomeProject/SomeProject
    

    then you can do:

    hg push https://bitbucket.org/MyUserName/SomeProject
    hg pull https://bitbucket.org/MyUserName/SomeProject
    

    However usually one sets the default path to save specifying the repo for each push and pull. To Change this either use the Synchronization tab in TortoiseHg or edit the projects .hg/hgrc file.

    the hgrc will prolly look like this:

    [paths]
    default = https://bitbucket.org/SomeProject/SomeProject
    

    change it to:

    [paths]
    default = https://bitbucket.org/MyUserName/SomeProject