Basic bazaar commands
<yambe:breadcrumb>Bazaar</yambe:breadcrumb>
Bazaar commands
Bazaar commands described below work in exactly same way in Linux and Windows.
Commands for working directly in repository as single user
Specifying username and email for bazaar commits
To specify username and email for bazaar commits use:
bzr whoami "<Name> <<Email>>"
For example
bzr whoami "Saurabh Barjatiya <saurabh@sbarjatiya.com>"
Creating new repository
To create a new bazaar repository use:
bzr init-repo <folder_name>
Creating a new branch in repository
To create a new branch in repository use:
bzr init <folder_name>
Note that branch folder should be sub-folder of a repository folder. Hence if repository is created in folder 'a' then branch(s) can be created as 'a/b', 'a/c', etc.
Adding files and folders to a branch
To add files or folders to a branch use:
bzr add <file_or_folder_name>
Checking status of files in a branch
To confirm whether files or folders have been added into branch for inclusion in next commit use:
bzr status
The status command is also used to check which files have been modified since last commit. Thus it helps in finding information about files whose status will get modified in next commit.
Commit changes to a branch
To commit changes to a branch use:
bzr commit -m "<commit_message>"
Check commit logs
To check commit logs use:
bzr log [<file_name>]
Forking or copying branch
To fork or copy a bazaar branch use
bzr branch <old_branch> <new_branch>
Note that the new branch should also be located inside a bazaar repository.
Checking differences between versions
To check difference between files of different versions use:
bzr diff -r <revision_no> [<file_name>]
Seeing a older version of a file
To see a older version of a file use:
bzr cat -r <file_name>
Export older version of branch to a folder
Some times it may be desired to export older revision of entire branch to a folder. This can be achieved using:
bzr export -r <revision> <destination_folder>
Note that destination folder in this case can be anywhere, including outsdie bazaar repository. Also note that the exported folder will not be automatically under version control.
Change current working revision number
To change current working revision number of branch use:
bzr update -r <revision_no>
Finding latest revision of current branch
To check latest revision of current branch use:
bzr revno
Finding current working revision number
If we change current revision number to older using 'bzr update -r <rev_no>' then we can find out the current working revision number using:
bzr version-info
Commands for working with centralized bazaar repository
Checkout a working copy of branch
To checkout a working copy of branch use:
bzr checkout <source_branch> <working_copy>
Note that in this case the working copy will have a reference to source branch so that changes can be committed to source branch
Commit changes to source branch
To commit changes to source branch from working copy use:
bzr commit -m "<commit_message>"
Receive updates from source branch
To receive updated changes from source branch use:
bzr update
Note the same command is also used to shift local version of files to latest revision. When a working copy commits changes to a source branch, the files of source branch do not automatically get updated to latest revision. Thus, 'bzr update' command can be used in such cases to obtain latest version of files in source branch
Find out which user made a change in particular line
To find out which user made a change in particular line of a file one can use:
bzr annotate <file-name>
Aliases for annotate are: ann, blame, praise
Commands for working with decentralized bazaar repository
Copy a branch for local modifications
To copy a branch for local modifications use:
bzr branch <source_branch> <destination_branch>
Commit changes to local branch
To commit changes to a local branch use:
bzr commit -m "<commit_message>"
Merge changes from a branch
To merge changes from a branch use:
bzr merge <source_branch>
Note that merge is used when two forks or copies of a branch have both been modified independently of each other. If only one of the copies is modified then 'bzr push' or 'bzr pull' can be used to send or receive updates from a mirror branch.
Listing files which have conflicts due to merge
To see list of file names which have conflicts due to merge use:
bzr conflicts
Resolving conflicts
To resolve a conflict in a file, edit file using preferred editor and make necessary modifications. Then to indifcate to bazaar that conflict has been resolved use:
bzr resolve <filename>
Note that to preserve changes one should ideally make a local commit after resolving conflicts.
Pushing or pulling changes to or from a mirror
If a copy of branch, say branch1, is made as branch2 and after copying all the changes are made in branch1 and not in branch2. Then all changes of branch2 can be pushed to branch1 using:
bzr push <location>
Other way round changes of branch2 can be pulled in to branch1 using:
bzr pull <location>
Thus, 'bzr push' and 'bzr pull' can be considered as special cased of =bzr merge= when there is guarantee that conflicts will not arsie as only of the two branches has been modified after fork/copy. The important difference between push/pull and merge is that in case of push/pull the commits are made to destination automatically. Hence there is no need to do a separate local commit after push or pull. But in case of merge modifications are made to files as per destinations branch but commit is not made locally, until 'bzr commit' is called explicitly.
<yambe:breadcrumb>Bazaar</yambe:breadcrumb>