A note on terminology -- version control systems are also known as revision control systems, source control systems, or source code management systems.
A note on Bazaar vs. Breezy -- Breezy is described as "a friendly fork of Bazaar". In this document, I will discuss Breezy. I believe that what I say will be true of and will cover Bazaar as well.
So, the commands we'll be using and learning are git, hg (for Mercurial), and brz for Breezy.
Some information sources on VCS in general:
- An article on version control at Wikipedia -- https://en.wikipedia.org/wiki/Version_control
- A comparison page at Wikipedia -- https://en.wikipedia.org/wiki/Comparison_of_source-code-hosting_facilities
- A list of VCSs at Wikipedia -- https://en.wikipedia.org/wiki/List_of_version-control_software
Information on specific VCS software:
For introductory information on basic workflows, see the "Pro Git" book, by Scott Chacon and Ben Straub, and which is available online -- https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
For instructions on how to do a typical workflow, see -- https://www.breezy-vcs.org/doc/en/tutorials/tutorial.html
The clone command in Git and Mercurial and the branch command in Breezy enable you to make a complete copy of a repository with all its latest commits and all its history.
One proviso is that the repository that results from this operation will not contain changes in the originating repository that have not been committed in the originating repository.
And, on Breezy at least, you can clone (create a branch) across the network with something like this:
brz branch sftp://dkuhlman@jackdaw:/home/dkuhlman/a1/VCS/Test01/Brz/brz1 brz2
For a list of other transports, see -- https://www.breezy-vcs.org/doc/en/_static/en/brz-en-quick-reference.pdf
You can also do a deep, recursive copy of a directory containing a repository, in which case you will also copy changes that have not been committed. For example, something like this (on Linux) will do that task:
$ cp --recursive repo1 repo2
Git and Mercurial do branches differently from Breezy. In both Git and Mercurial, branches can be created within a repository; then you can switch from working on one branch rather than another with the git update <branch-name> or hg update <branch-name>.
Here are some commands that you will likely use for creating and using branches in Git:
# Create new branch named "featureA". $ git branch featureA # Switch to using and working on files in branch featureA. $ git switch featureA # git commit -m "changes to featureA" # Show names of existing branches. $ git branch # Switch back to branch "master", then merge changes committed in branch "featureA". $ git switch master # Merge changes in branch "featureA" into branch "master". $ git merge featureA # Delete branch "featureA". $ git branch -d featureA
For more information, see "Branching and Merging" here -- https://git-scm.com/docs
Here are some commands that you will likely use for creating and using branches in Mercurial:
# Create new branch named "featureA". $ hg branch featureA # hg commit -m "changes to featureA" # Show names of existing branches. $ hg branches # Switch back to branch "default", then merge changes committed in branch "featureA". $ hg update master # Merge changes in branch "featureA" into branch "default". # Then commit them in branch default. $ hg merge featureA $ hg commit -m "Merge from featureA" # Finish with branch "featureA". # Then switch back to working on the "default" branch. $ hg commit --close-branch -m "Finished with featureA" $ hg update default
For more information, see -- https://www.mercurial-scm.org/guide#collaborative_development
Branches are quite different in Breezy, where a branch is just a separate directory containing a copy of a repository. In fact, the command for creating a new branch that is a "clone" of an existing branch is:
$ brz branch old_repo new_repo
After creating that new branch, i.e. a new directory with a copy of the original, you change directory (cd) to the new repository's directory, make changes to files, commit, etc as you normally would.
And, when you want to merge those changes back into the original repository, you cd back to that directory and do a merge:
$ cd old_repo $ hg merge ../new_repo
Here is a sequence of commands that does some of those things:
# Make a branch/clone of the original repo. $ brz branch original featureA # Switch to the new branch/directory. $ cd featureA # Change some files, then commit those changes. $ brz commit -m "Changes in featureA" # Switch back the the original repo, # then merge changes from repo "featureA" $ cd ../original $ brz merge ../featureA $ brz commit -m "Merged changes from branch featureA" # If we are finished with the branch, delete it. # *But*, becareful. We can't get it back. # Might want to archive it instead. $ cd .. # Safer -- archive with zip and permanently delete it: $ zip -m -r featureAarchive.zip featureA # Or -- archive with tar and xz, then permanently delete it: $ tar -cJf featureAarchive.tar.xz featureA $ rm -rf featureA
You can save disk space (especially if you have a large repository and are making many branches) by using a shared repository. For information about that, see -- https://www.breezy-vcs.org/doc/en/user-guide/branching_a_project.html#a-reminder-about-shared-repositories
You can read about working as a team, collaboration, and workflows here:
- Mercurial -- For information about workflows, see -- https://www.mercurial-scm.org/guide.
- Breezy -- https://breezy-vcs.org/doc/en/user-guide/index.html. Look for "workflow", "team collaboration", etc. In contrast, if you're using Breezy for personal, individual, solo use, look for the topics arranged under "Personal version control".