-
Notifications
You must be signed in to change notification settings - Fork 1
Clone
Altcmd does not currently implement "real" clones that exist on remote machines. But, to provide a proof of concept, it does let you create a clone on the same machine as the origin.
You create a clone from the Windows command line (you cannot do it from within an altcmd session).
C:\Alt> altcmd clone origin steve
Creating C:\Alt\steve
Cloning from origin
C:\Alt>
This clone command creates a folder that sits alongside the original store, then copies over all the files. The only difference is that the new store contains a new .root file.
{
"StoreId": "2514ef99-d38f-4ac5-8715-7dc6314b571e",
"UpstreamId": "3ed0cad0-dbb8-42ea-8ed1-f42f91877d5e",
"UpstreamLocation": "C:\\Alt\\origin",
"PushTimes": null
}
The .root file holds a new ID for the new store, as well as the location of the origin. Open the new store using altcmd to see what you have.
C:\Alt> altcmd steve
Opened steve (current branch is steve)
^[4]> ls
0 commands in 0 local branches
8 commands in 2 remote branches (not listed)
You may well think that the clone is quite empty, but that is because the ls command (branch --list) only lists local branches by default. But the command counts do suggest that remote branches are in fact present. When you are working with a clone, two branch listing options are relevant:
- --remotes lists only the remote branches
- --all lists both the remote and local branches
When you repeat things with --all, you get the complete picture.
^[4]> ls --all
* ^/steve
^/steve/work
0 commands in 0 local branches
8 commands in 2 remote branches
At this stage, the only branches you have are remote branches that have been imported from the origin. The ^/steve branch is exactly the same as the /origin branch in the upstream store (except for a name change, which arises because the command data is now present in another folder that has a different name).
You can identify upstream branches because their branch path is displayed with a leading ^ character. Upstream branches are read-only. You can browse the content of any remote branch by switching to them with a cd (checkout) command. But you cannot change them.
Changes can only be made in a new branch from one of the upstream branches. You can either branch explicitly, or you can get altcmd to automatically branch for you, like this:
^[4]> cd work
^work[4]> name Tracey
Created (and switched to) /steve/work/+
work/+[2]> ls -a
^/steve
^/steve/work
* /steve/work/+ (ahead of parent by 1)
2 commands in 1 local branch
8 commands in 2 remote branches
When a data entry command is entered while you are on an upstream branch, altcmd first creates a new branch called +, switches to that new branch, and writes the new command there.
So having added Tracey in the local branch, suppose you want to merge her into the parent. That is easily done if the parent is also a local branch. But it won't work here:
work/+[2]> cd ..
^work[4]> merge +
You are currently on a remote branch (use the push command instead)
^work[4]>
Altcmd will only let you modify local branches. And the merge command shown here is attempting to modify a remote. To get Tracey into the parent, you have to first transfer her back to the origin using the push command.