Search code examples
version-controlmercurialtortoisehgrevert

How can I commit/push changes to a "live" branch and then keep working on my "test/dev" branch?


I'm very new to working on larger projects and using any form of version control, so please bear with me.

I have a project running on a local/intranet webserver. I'm using mercurial for version control with hgworkbench/turtoisehg as a GUI. So far I've simply commited and pushed my changes to the repository into the default branch.

Now it's time to deploy the project to the live server for the first time. In order to run on the live server, I have to make a couple of changes to the project, mostly replacing connection strings, domain names, and links/references. After changing all this, I commit these changes to a new branch deployment. (Another person will take care of the actual deployment from there.)

Once I have pushed the modified files to the deploymentbranch I want my local files back to the last version of the defaultbranch and continue to work from there (let's say the last ref# is 42, the push to the new branch is ref# 43; so i want my lokal system to have the status of #42 and #44 should then be the direct child of #42 in the default branch.)

How can I do this without somehow breaking any of the branches?


Solution

  • To see the current branch:

    hg branch
    

    (From TortoiseHg Workbench, you see the current branch next to "* Working Directory *" at the top.)

    To update the working directory to the default branch:

    hg update default
    

    (From TortoiseHg, use Repository --> Update...)

    Now that you are in the default branch, you can commit your changes as you were doing before. Once you are ready for another deployment, you can merge the latest changes from default to deployment:

    hg update deployment
    hg merge default
    hg commit
    

    (From TortoiseHg, first update to the target branch, deployment in this case. Then right-click on the tip of the default branch and select "Merge with local..." And don't forget to commit the merge once you have reviewed it.)