2977.1.3
by Ian Clatworthy
1st cut at the 'Personal version control' chapter |
1 |
Recording changes |
2 |
================= |
|
3 |
||
4 |
bzr commit |
|
5 |
---------- |
|
6 |
||
7 |
When the working tree state is satisfactory, it can be **committed** to |
|
4853.1.1
by Patrick Regan
Removed trailing whitespace from files in doc directory |
8 |
the branch, creating a new revision holding a snapshot of that state. |
2977.1.3
by Ian Clatworthy
1st cut at the 'Personal version control' chapter |
9 |
|
10 |
The **commit** command takes a message describing the changes in the |
|
11 |
revision. It also records your userid, the current time and timezone, and |
|
12 |
the inventory and contents of the tree. The commit message is specified |
|
13 |
by the ``-m`` or ``--message`` option. You can enter a multi-line commit |
|
14 |
message; in most shells you can enter this just by leaving the quotes open |
|
15 |
at the end of the line. |
|
16 |
||
17 |
:: |
|
18 |
||
19 |
% bzr commit -m "added my first file" |
|
20 |
||
21 |
You can also use the ``-F`` option to take the message from a file. Some |
|
22 |
people like to make notes for a commit message while they work, then |
|
23 |
review the diff to make sure they did what they said they did. (This file |
|
24 |
can also be useful when you pick up your work after a break.) |
|
25 |
||
26 |
Message from an editor |
|
27 |
---------------------- |
|
28 |
||
29 |
If you use neither the ``-m`` nor the ``-F`` option then bzr will open an |
|
30 |
editor for you to enter a message. The editor to run is controlled by |
|
31 |
your ``$VISUAL`` or ``$EDITOR`` environment variable, which can be overridden |
|
32 |
by the ``editor`` setting in ``~/.bazaar/bazaar.conf``; ``$BZR_EDITOR`` will |
|
33 |
override either of the above mentioned editor options. If you quit the |
|
34 |
editor without making any changes, the commit will be cancelled. |
|
35 |
||
36 |
The file that is opened in the editor contains a horizontal line. The part |
|
37 |
of the file below this line is included for information only, and will not |
|
38 |
form part of the commit message. Below the separator is shown the list of |
|
39 |
files that are changed in the commit. You should write your message above |
|
40 |
the line, and then save the file and exit. |
|
41 |
||
42 |
If you would like to see the diff that will be committed as you edit the |
|
43 |
message you can use the ``--show-diff`` option to ``commit``. This will include |
|
44 |
the diff in the editor when it is opened, below the separator and the |
|
45 |
information about the files that will be committed. This means that you can |
|
46 |
read it as you write the message, but the diff itself wont be seen in the |
|
47 |
commit message when you have finished. If you would like parts to be |
|
48 |
included in the message you can copy and paste them above the separator. |
|
49 |
||
50 |
Selective commit |
|
51 |
---------------- |
|
52 |
||
53 |
If you give file or directory names on the commit command line then only |
|
54 |
the changes to those files will be committed. For example:: |
|
55 |
||
56 |
% bzr commit -m "documentation fix" commit.py |
|
57 |
||
58 |
By default bzr always commits all changes to the tree, even if run from a |
|
59 |
subdirectory. To commit from only the current directory down, use:: |
|
60 |
||
61 |
% bzr commit . |
|
62 |
||
4056.2.4
by James Westby
Document the --author option to commit. |
63 |
Giving credit for a change |
64 |
-------------------------- |
|
65 |
||
66 |
If you didn't actually write the changes that you are about to commit, for instance |
|
67 |
if you are applying a patch from someone else, you can use the ``--author`` commit |
|
68 |
option to give them credit for the change:: |
|
69 |
||
70 |
% bzr commit --author "Jane Rey <jrey@example.com>" |
|
71 |
||
72 |
The person that you specify there will be recorded as the "author" of the revision, |
|
73 |
and you will be recorded as the "committer" of the revision. |
|
74 |
||
75 |
If more than one person works on the changes for a revision, for instance if you |
|
76 |
are pair-programming, then you can record this by specifying ``--author`` multiple |
|
77 |
times:: |
|
78 |
||
79 |
% bzr commit --author "Jane Rey <jrey@example.com>" \ |
|
80 |
--author "John Doe <jdoe@example.com>" |
|
81 |