~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/en/mini-tutorial/index.txt

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-30 18:28:17 UTC
  • mfrom: (5967.10.2 test-cat)
  • Revision ID: pqm@pqm.ubuntu.com-20110630182817-83a5q9r9rxfkdn8r
(mbp) don't use subprocesses for testing cat (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
57
57
Let's suppose we want to store a new project under Bazaar.  First, we'll
58
58
make a *repository directory* to hold all our work related to this
59
 
project, where developers can create branches to test development of
60
 
specific features or, more generally, modifications to the working file
61
 
set.  
62
 
 
63
 
After creating the repository, change to that directory, and create the
64
 
project's main trunk branch.
 
59
project.  We can then have multiple branch directories under here, and
 
60
they'll all store the committed history in the repository.
65
61
 
66
62
::
67
63
 
68
 
  $ bzr init-repo sample
69
 
  Shared repository with trees (format: 2a)
70
 
  Location:
71
 
    shared repository: sample
72
 
  $ bzr init sample/trunk
73
 
  $ cd sample/trunk
74
 
  Created a repository tree (format: 2a)                                         
75
 
  Using shared repository: /home/john/sample/
76
 
 
77
 
 
78
 
Adding files
79
 
============
80
 
 
81
 
Now that we have the trunk, we need to move to that directory and
82
 
create some example files for the first version of that project.  Create
83
 
a file ``test1.txt`` using a text editor (like emacs, nano, or notepad),
84
 
and save it.  Then we'll "add" the file, which tells bzr we want it to
85
 
track changes::
86
 
 
87
 
  bzr add test1.txt
88
 
 
89
 
and then commit, which saves a snapshot of all versioned files::
90
 
 
91
 
  bzr commit -m "Added first line of text"
 
64
  bzr init-repo sample
 
65
  cd sample
 
66
  bzr init trunk
 
67
  cd trunk
92
68
 
93
69
 
94
70
Making changes to your files
95
71
============================
96
72
 
97
 
 
98
73
Let's change a file and commit that change to your branch.
99
74
 
100
 
Edit ``test1.txt`` in your favourite editor, then use ``bzr add`` to tell bzr
101
 
to track changes to this file ::
102
 
 
103
 
  $ echo test test test > test1.txt 
104
 
  $ bzr add test1.txt
105
 
  adding test1.txt
106
 
 
107
 
`bzr diff` shows the changes between the last revision in this branch, and your
108
 
current tree (or, with the ``-r`` option, between any two trees). ::
 
75
Edit ``test1.txt`` in your favourite editor, then check what have you done::
109
76
 
110
77
 $ bzr diff
111
78
 === modified file 'test1.txt'
117
84
Commit your work to the Bazaar branch::
118
85
 
119
86
  $ bzr commit -m "Added first line of text"
120
 
  Committing to: /home/john/sample/trunk/                             
121
 
  added test1.txt
122
 
  Committed revision 1.
 
87
  Committed revision 2.
 
88
 
123
89
 
124
90
Viewing the revision log
125
91
========================
127
93
You can see the history of your branch by browsing its log::
128
94
 
129
95
  $ bzr log
 
96
  ------------------------------------------------------------
 
97
  revno: 2
 
98
  committer: John Doe <john.doe@gmail.com>
 
99
  branch nick: myproject
 
100
  timestamp: Mon 2007-10-08 17:56:14 +0000
 
101
  message:
 
102
    Added first line of text
 
103
  ------------------------------------------------------------
130
104
  revno: 1
131
105
  committer: John Doe <john.doe@gmail.com>
132
 
  branch nick: trunk
 
106
  branch nick: myproject
133
107
  timestamp: Mon 2006-10-08 17:46:22 +0000
134
108
  message:
135
109
    Initial import
142
116
software projects. You can use it to publish your branch.  (You can 
143
117
also publish branches onto your own server or other hosting services.)
144
118
 
145
 
The steps to publishing branches on Launchpad are:
146
 
 
147
 
1. Create a Launchpad account: visit the `Launchpad login page`_ and choose to create a new account.
148
 
    
149
 
.. _Launchpad login page: https://launchpad.net/+login
150
 
    
151
 
2. Bazaar uses the SSH encryption and authentication protocol to connect
152
 
   to Launchpad.  You need to first `create an SSH key`_ on your own computer,
153
 
   by running the command::
154
 
    
155
 
       $ ssh-keygen
156
 
 
157
 
.. _create an SSH key: https://help.launchpad.net/YourAccount/CreatingAnSSHKeyPair    
158
 
       
159
 
3. `Upload your SSH public key to Launchpad`_.
160
 
 
161
 
.. _Upload your SSH public key to Launchpad: https://launchpad.net/~/+editsshkeys
162
 
    
163
 
4. `Make a team for your project`_.  Even if you're starting as the only
164
 
   developer on this project, creating a new one now will let you more
165
 
   easily add other people later.
166
 
 
167
 
.. _Make a team for your project: https://help.launchpad.net/Teams/CreatingAndRunning
168
 
      
169
 
5. `Create a project`_.
170
 
  
171
 
.. _Create a project: https://help.launchpad.net/Projects/Registering
172
 
 
173
 
6. Tell Bazaar your Launchpad account name.  If your account is john.doe, type ::
174
 
  
175
 
      $ bzr launchpad-login john.doe
176
 
 
177
 
7. `Push the branch for your project`_.  Once you've committed your changes 
178
 
   locally, you can publish them as the trunk of your new project by saying
179
 
    
180
 
       $ bzr push lp:~sample-developers/sample/trunk
181
 
       
182
 
   (Of course, using the team and project names you just chose.)
183
 
 
184
 
.. _Push the branch for your project: https://help.launchpad.net/Code/UploadingABranch
 
119
If you don't have a Launchpad account, follow the `account signup guide`_
 
120
and `register an SSH key`_ in your new Launchpad account.
 
121
 
 
122
.. _account signup guide: https://help.launchpad.net/CreatingYourLaunchpadAccount
 
123
.. _register an SSH key: https://launchpad.net/people/+me/+editsshkeys
 
124
 
 
125
Replacing ``john.doe`` with your own Launchpad username, type::
 
126
 
 
127
 $ bzr push lp:~john.doe/+junk/myproject
 
128
 
 
129
**Note**: ``+junk`` is a place to store experimental branches not
 
130
associated with any particular project.  Normally, you should push a
 
131
project into an existing project, or register a new project through the
 
132
web interface.
 
133
 
 
134
Now, anyone can create their own copy of your branch by typing::
 
135
 
 
136
 $ bzr branch lp:~john.doe/+junk/myproject
 
137
 
 
138
You can also see information about your branch, including its revision
 
139
history, at https://code.launchpad.net/people/+me/+junk/myproject
 
140
 
185
141
 
186
142
Creating your own copy of another branch
187
143
========================================