it:ad:mercurial:howto:branch_and_merge

IT:AD:Mercurial:HowTo:Branch and Merge

Cloning

Cloning is the process of pulling down a second copy of the Repo, and working on it.

CloneA -> [a] -> [b] -> [c] 
//Download another repo
CloneB -> [a] -> [b]
//and work on it:
CloneB -> [a] -> [b] -> [x] -> [y]
//unaware of changes made in any other branch
CloneA -> [a] -> [b] -> [c] -> [d]

When ready to checkin changes made to CloneB, you'll have to first pull down and Merge any changes from CloneA before you can push the changes you made.

  • Pros:
    • Great to take a copy and mess around to see if the idea can be done, and then chuck it in.
  • Cons:
    • Can checkin but not push until you're ready to add the code to CloneA
    • No history beyond whatever you put in your notes.
    • It's not really branching, as much as simply working off from RepoA on your own till done.
    • More of an all or nothing solution.

Named Branches

The alternate is to use the same Repo with Named Branches.

By default checkins are done to the 'default' branch (note that when it's default, you don't even see it).

Checkin code to a named branch by following the following steps:

  • Checkin, and on the Commit screen, change the Branch from default to something else.
    • Can be anything, but recommend that you stick to
      • investigations/xxx
      • branches/xxx
      • tags/v0.x

  • Once set, subsequent checkins will be checked in with that name.
  • When someone else downloads the repo, from their point of view (ie Default), they'll see:

  • IMPORTANT: First Checkin your codes to your side branch (investigations/01)
    • If you don't check in these changes, they'll be lost when you switch over.
  • Perform an update to switch branch:
  • /home/skysigal/public_html/data/pages/it/ad/mercurial/howto/branch_and_merge.txt
  • Last modified: 2023/11/04 01:49
  • by 127.0.0.1