Skip to content

Branches and Folders

steve-stanton edited this page Sep 17, 2019 · 9 revisions

When you create a new store, you get one branch (with a name that matches the name of the store). To create a child branch, run altcmd and use the branch command:

   C:\Alt> altcmd origin
   Opened origin (current branch is origin)
   [2]> branch work
   Created /origin/work
   [2]>

When you create a new branch, the current working branch does not get changed at all (that is why the prompt still says [2]). The branch command creates a sub-folder called "work" and creates files in that new folder. If you look in C:\Alt\origin\work, you will find two files:

0.json

0.json holds a description of the branch command that you just ran.

{
  "CmdName": "ICreateBranch",
  "Sequence": 0,
  "CreatedAt": "2019-09-10T19:35:32.5991115Z",
  "Name": "work",
  "CommandCount": 2
}

The CommandCount property records the place in the parent where the branch was taken. This says how many commands have been inherited from the parent.

{guid}.ac

A new AC file gets created to hold the metadata for the new branch.

{
  "StoreId": "3ed0cad0-dbb8-42ea-8ed1-f42f91877d5e",
  "ParentId": "3ed0cad0-dbb8-42ea-8ed1-f42f91877d5e",
  "BranchId": "45855519-aa5e-4836-95fa-f8cc6e35e143",
  "CreatedAt": "2019-09-10T19:35:32",
  "CommandCount": 1,
  "CommandDiscount": 1,
  "RefreshCount": 2,
  "RefreshDiscount": 0,
  "LastMerge": {},
  "LastPush": 0,
  "IsCompleted": false
}

Without wanting to go into every detail, the following properties are worth noting:

  • StoreId is the ID of the command store that the branch was created in.

  • ParentId holds the ID of the parent branch. In this case, that also matches the value for StoreId because the parent is also the root branch.

  • CommandCount is the number of commands in the new branch (referring to 0.json). This will increase as additional commands are appended to the branch.

  • RefreshCount is the number of commands in the parent that the child branch knows about. This will increase each time the child merges commands from the parent.

The branch command has syntax like that in git. So as well as creating new branches, you can also list the branches in the store.

   [2]> branch --list
   *  /origin
      /origin/work
	  
   3 commands in 2 local branches
   [2]>

The line preceded with the * shows the current branch is still the root branch. To actually switch to the new branch, use the checkout command:

   [2]> checkout work
   work[1]>

When you switch branch, the command prompt also changes to remind you what branch you are currently working with.

Command Aliases

Altcmd tries to provide command line syntax like that used by the git command line. However, a number of command aliases can also be used.

  • branch = mkdir or md

  • branch --list = ls or dir

  • checkout = cd

Given that each branch is a folder, and they have exactly the same hierarchy, you may well find it is more natural to use the folder aliases when working with branches.

Clone this wiki locally