]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/devel/git-starting.itexi
f3949a12c2c1669c07aed6185d2306bcced2e39d
[lilypond.git] / Documentation / devel / git-starting.itexi
1 @c -*- coding: us-ascii; mode: texinfo; -*-
2 @node Starting with git
3 @chapter Starting with git
4
5 @menu
6 * Getting the source code::     
7 * Updating the source code::    
8 * Sharing your changes::        
9 * Other interesting Git commands::  
10 * Applying git patches::        
11 * Git on Windows::              
12 @end menu
13
14
15 @node Getting the source code
16 @section Getting the source code
17
18 The source code is kept in a git respository.
19
20 @warning{These instructions assume that you are using the
21 command-line version of git 1.5 or higher.}
22
23
24 @menu
25 * Main source code::            
26 * Website source code::         
27 * Documentation translations source code::  
28 * Other branches::              
29 * Other locations for git::     
30 * Git user configuration::      
31 @end menu
32
33 @node Main source code
34 @subsection Main source code
35
36 To get the main source code and documentation,
37
38 FIXME: test this!!!
39
40 @example
41 mkdir lilypond; cd lilypond
42 git init-db
43 git remote add -f -t master -m master origin git://git.sv.gnu.org/lilypond.git/
44 git checkout -b master origin/master
45 @end example
46
47
48 @node Website source code
49 @subsection Website source code
50
51 To get the website (including translations),
52
53 @example
54 mkdir lilyweb ; cd lilyweb
55 git init-db
56 git remote add -f -t web -m web origin git://git.sv.gnu.org/lilypond.git/
57 git checkout -b web origin/web
58 @end example
59
60
61 @node Documentation translations source code
62 @subsection Documentation translations source code
63
64 To translate the documentation (@emph{not} the website),
65
66 FIXME: change
67
68 @example
69 mkdir lilytranslate ; cd lilytranslate
70 git init-db
71 git remote add -f -t web -m web origin git://git.sv.gnu.org/lilypond.git/
72 git checkout -b web origin/web
73 @end example
74
75
76 @node Other branches
77 @subsection Other branches
78
79 Most contributors will never need to touch the other branches.  If
80 you wish to do so, you will need more familiarity with git.
81
82 @itemize
83
84 @item @code{gub}:
85 This stores the Grand Unified Binary, our cross-platform building
86 tool.
87
88 @example
89 FIXME: insert new gub addy
90 @end example
91
92 @item @code{dev/XYZ}:
93 These branches are for individual developers.  They store code
94 which is not yet stable enough to be added to the @code{master}
95 branch.
96
97 @item @code{stable/XYZ}:
98 The branches are kept for archival reasons.
99
100 @end itemize
101
102
103 @node Other locations for git
104 @subsection Other locations for git
105
106 If you have difficulty connecting to most of the repositories
107 listed in earlier sections, try:
108
109 @example
110 git://git.sv.gnu.org/lilypond.git
111 http://git.sv.gnu.org/r/lilypond.git
112 ssh://git.sv.gnu.org/srv/git/lilypond.git
113 @end example
114
115
116 @node Git user configuration
117 @subsection Git user configuration
118
119 To configure git to automatically use your name and email address
120 for patches,
121
122 @example
123 git config --global user.name "MYNAME"
124 git config --global user.email myemail@@example.net
125 @end example
126
127
128 @node Updating the source code
129 @section Updating the source code
130
131 @menu
132 * Importance of updating::      
133 * Update command::              
134 * Resolving conflicts::         
135 * Technical notes::             
136 @end menu
137
138 @node Importance of updating
139 @subsection Importance of updating
140
141 In a large project like LilyPond, contributors sometimes edit the
142 same file at the same time.  As long as everybody updates their
143 version of the file with the most recent changes (@qq{pull}ing),
144 there are generally no problems with this multiple-person editing.
145 However, serious problems can arise if you do not pull before
146 attempting commit.
147
148 @node Update command
149 @subsection Updating command
150
151 Whenever you are asked to pull, it means you should update your
152 local copy of the repository with the changes made by others on
153 the remote @code{git.sv.gnu.org} repository:
154
155 @example
156 git pull origin
157 @end example
158
159 @node Resolving conflicts
160 @subsection Resolving conflicts
161
162 Occasionally an update may result in conflicts -- this happens
163 when you and somebody else hae modified the same part of the same
164 file and git cannot figure out how to merge the two versions
165 together.  When this happens, you must manually merge the two
166 versions.
167
168 @example
169 TODO
170 @end example
171
172
173 @node Technical notes
174 @subsection Technical notes
175
176 Let's explain a bit of Git vocabulary.  The @code{git pull
177 origin} command is just a shortcut for this command:
178
179 @example
180 git pull git://git.sv.gnu.org/lilypond.git/ MY-BRANCH:origin/MY-BRANCH
181 @end example
182
183 A commit is a set of changes made to the sources; it also includes the
184 committish of the parent commit, the name and e-mail of the author
185 (the person who wrote the changes), the name and e-mail of the
186 committer (the person who brings these changes into the git
187 repository), and a commit message.
188
189 A committish is the SHA1 checksum of a commit, a number made of 40
190 hexadecimal digits, which acts as the internal unique identifier for
191 this commit.  To refer to a particular revision, don't use vague
192 references like the (approximative) date, simply copy'n'paste the
193 committish.
194
195 A branch is a tree (in the mathematical or computer science sense) of
196 commits, and the topmost commit of this branch is called a head.
197
198 The "git fetch" command above has created a branch called origin/web
199 in your local Git repository.  As this branch is a copy of the remote
200 branch web from git.sv.gnu.org LilyPond repository, it is
201 called a `remote branch', and is meant to track the changes on the
202 branch from git.sv.gnu.org: it will be updated every time you run 'git
203 pull' or 'git fetch' with this branch reference as argument, e.g.
204 by using .git/remotes/web remote file when running 'git fetch web'.
205
206 The 'git checkout' command above has created a branch named 'web'.  At
207 the beginning, this branch is identical to 'origin/web', but it will
208 differ as soon as you make changes, e.g. adding newly translated
209 pages.  Whenever you pull, you merge the changes from origin/web and
210 your web branch since the last pulling.  If you do not have push
211 (i.e. "write") access on git.sv.gnu.org, your web branch will always
212 differ from origin/web.  In this case, remember that other people
213 working like you on the remote web branch of
214 git://git.sv.gnu.org/lilypond.git/ know nothing about your own web
215 branch: this means that whenever you use a committish or make a patch,
216 others expect you to take the lastest commit of origin/web branch as a
217 reference.
218
219 This README tries to explain most of Git commands needed for
220 translating the web site.  However, you are invited to read
221 further documentation to make git more familiar to you; for
222 instance, take a look at @uref{http://git.or.cz/gitwiki/},
223 especially GitDocumentation and GitGlossary; a good alternative to
224 reading the wiki is reading the first two chapters of Git User's
225 Manual at
226 @uref{http://www.kernel.org/pub/software/scm/git/docs/user-manual.html}
227
228
229
230
231 @node Sharing your changes
232 @section Sharing your changes
233
234
235 @menu
236 * Producing a patch::           
237 * Committing directly::         
238 @end menu
239
240 @node Producing a patch
241 @subsection Producing a patch
242
243 Once you have finished editing your files, checked that your
244 changes meet the @ref{Code style} and/or @ref{Documentation
245 policy}, and checked that the entire thing compiles, you may
246
247 @example
248 git commit -a 
249 git-format-patch HEAD
250 @end example
251
252 Send an email to @email{lilypond-devel@@gnu.org} with the diff as
253 an attachment.
254
255
256 @node Committing directly
257 @subsection Committing directly
258
259 Most contributors do not have permission to commit directly.  If
260 you do, edit @file{.git/config} to contain
261
262 @example
263 FIXME?
264 @end example
265
266 You may then @code{git push}.
267
268
269 @node Other interesting Git commands
270 @section Other interesting Git commands
271
272 The commands above don't only bring you the latest version of the
273 sources, but also the full history of revisions (revisons, also
274 called commits, are changes made to the sources), stored in the
275 .git directory.  You can browse this history with
276
277 @example
278 git log     # only shows the logs (author, committish and commit message)
279 git log -p  # also shows diffs
280 gitk        # shows history graphically
281 @end example
282
283
284 @node Applying git patches
285 @section Applying git patches
286
287 Well-formed git patches should be committed with
288
289 @example
290 git-am
291 @end example
292
293 Patches created without @code{git-format-patch} should be
294 committed with
295
296 @example
297 git-apply
298 @end example
299
300
301
302 @node Git on Windows
303 @section Git on Windows
304
305 @c Some of this may duplicate stuff in other sections
306 @c Clear this up later  -td
307
308 @subsection Background to nomenclature
309
310 Git is a system for tracking the changes made to source files by
311 a distributed set of editors.  It is designed to work without a
312 master repository, but we have chosen to have a master respository
313 for LilyPond files.  Editors hold local copies of the master
314 repository together with any changes they have made locally.  Local
315 changes are held in a local @q{branch}, of which there may be
316 several.  The files in the local repository always correspond to
317 those on the currently @q{checked out} local branch.
318
319 Files are edited on a local branch, and in that state the
320 changes are said to be @q{unstaged}.  When editing is complete, the
321 changes are moved to being @q{staged for commit}, and finally the
322 changes are @q{committed} to the local branch.  Once
323 committed, the changes are given a unique reference number called the
324 @q{Committish} which identifies them to Git.  Such committed changes
325 can be sent to the master repository by @q{pushing} them (if you
326 have write permission) or by sending them by email to someone who
327 has, either complete or as a @q{diff} or @q{patch} (which send
328 just the differences from master).
329
330 @subsection Installing git
331
332 Obtain Git from
333 @uref{http://code.google.com/p/msysgit/downloads/list}.
334 (Note, not msysGit, which is for Git developers) and
335 install.  Start Git by clicking on the desktop icon.
336 This will bring up a command line bash shell.  This will be
337 unfamiliar to most Windows users, so follow these
338 instructions carefully.  Commands are entered at a $ prompt
339 and are terminated by keying a newline.
340
341 @subsection Initialising Git
342
343 Decide where you wish to place your local Git repository,
344 creating the folders in Windows as necessary.  Here we
345 call the folder to contain the repository [path]/Git.
346 You will need to have space for around 150Mbytes.
347
348 In the git bash shell type
349
350 @example
351 cd [path]/Git
352 @end example
353
354 to position the shell at your new Git repository.
355
356 Note: if [path] contains folders with names containing
357 spaces use
358
359 @example
360 cd "[path]/Git"
361 @end example
362
363 Then type
364
365 @example
366 git init
367 @end example
368
369 to initialize your Git repository.
370
371 Then type (all on one line; the shell will wrap automatically)
372
373 @example
374 git remote add -f -t master origin git://git.sv.gnu.org/lilypond.git
375 @end example
376
377 to download the lilypond master files.
378
379 @warning{Be patient!  Even on a broadband connection this can take
380 10 minutes or more.  Wait for lots of [new tag] messages
381 and the $ prompt.}
382
383 We now need to generate a local copy of the downloaded files
384 in a new local branch.  Your local branch needs to have a
385 name, here we call it @q{lily-local} - make up your own.
386 Then, finally, type
387
388 @example
389 git checkout -b lily-local origin/master
390 @end example
391
392 to create the lily-local branch containing the local copies of the
393 master files.  You will be advised your local branch has been set
394 up to track the remote branch.
395
396 Return to Windows and look in your Git repository.  You
397 should see lots of folders.  The LilyPond documentation
398 can be found in Git/Documentation/user.
399
400 Terminate the Git bash shell with the exit command.
401
402 @subsection Git GUI
403
404 Almost all subsequent work will use the Git Graphical User
405 Interface, which avoids having to type command line
406 commands. To start Git GUI first start the Git bash shell by
407 clicking on the desktop icon, and type
408
409 @example
410 cd [path]/Git
411 git gui
412 @end example
413
414 The Git GUI will open in a new window.  It contains four panels
415 and 7 pull-down menus.  At this stage do not use any of the
416 commands under Branch, Commit, Merge or Remote.  These will
417 be explained later.
418
419 The two panels on the left contain the names of files which
420 you are in the process of editing (Unstaged Changes),and
421 files you have finished editing and have staged ready for
422 committing (Staged Changes).  At this stage these panels will
423 be empty as your local branch is the same as the master branch.
424 After a file has been edited and saved the top panel on the right
425 will display the differences between the edited file selected
426 from one of the left panels and the one on master.  The
427 final panel at bottom right is used to enter a descriptive
428 message about the change before committing a file.
429
430 The Git GUI is terminated by entering CNTL-Q while it is the
431 active window or by clicking on the usual Windows close-window
432 widget.
433
434 @subsection Personalising your local git repository
435
436 Open the Git GUI, click on
437
438 @example
439 Edit -> Options
440 @end example
441
442 and enter your name and email address in the
443 left-hand (Git Repository) panel.  Leave everything
444 else unchanged and save it.
445
446 @subsection Checking out a branch
447
448 At this stage you have two branches in your local repository,
449 both identical.  To see them click on
450
451 @example
452 Branch -> Checkout
453 @end example
454
455 You should have one local branch called lily-local and one
456 tracking branch called origin/master.
457
458 When a particular branch is selected, i.e., checked out, the
459 files visible in your repository are changed to reflect the
460 changes made on that branch.
461
462 @subsection Updating files from master
463
464 Before starting the editing of a file ensure you have the
465 latest copy from master by first clicking
466
467 @example
468 Remote -> Fetch from -> origin
469 @end example
470
471 in the Git GUI.
472
473 This will place details of all the changes made by others
474 into the @q{origin/master} branch of the tracking branches
475 in your git repository.  You can see these files by checking
476 out this branch.  This will not affect any files
477 you have modified in any of your local branches.
478
479 To merge the changed files into your local branch click on
480
481 @example
482 Merge -> Local Merge
483 @end example
484
485 and if necessary select the local branch into which the merge
486 is to be made.
487
488 This will update all the files in that branch to reflect the
489 currect state of the origin/master branch.  If any of the changes
490 conflict with changes you have made yourself recently
491 you will be notified of the conflict (see below).
492
493 @subsection Editing files
494
495 Simply edit the files in your local Git repository with
496 your favourite editor and save them back there.  If any file contains
497 non-ASCII characters ensure you save it in UTF8 format.  Git will
498 detect any changes whenever you restart Git GUI
499 and the file names will then be listed in the Unstaged Changes panel.
500 Or you can click the Rescan button to refresh the panel
501 contents at any time.  You may break off and resume at
502 editing any time.
503
504 The changes you have made may be displayed in diff form
505 in the top right-hand panel by clicking on the name in
506 Git GUI.
507
508 When your editing is complete, move the files from being
509 Unstaged to Staged by clicking the document symbol to
510 the left of each name.  If you change your mind it can
511 be moved back by clicking on the ticked box to the
512 left of the name.
513
514 If you wish to cancel your changes the original version
515 may be recovered at any time before a commit is made
516 by selecting Commit -> Revert changes.  This will even
517 recover a deleted file.
518
519 Finally the changes you have made may be committed to
520 your local branch by entering a brief message in
521 the Commit Message box and clicking the Commit button.
522
523 @sebsection Sending changes to origin/master
524
525 If you do not have write access to master you will
526 need to send your changes by email to someone who does.
527
528 First you need to create a diff or patch file containing
529 your changes.  To create this, the file must first be
530 committed.  Then terminate the Git GUI.  In the
531 git bash shell first cd to your Git repository with
532
533 @example
534 cd [path]/Git
535 @end example
536
537 if necessary, then produce the patch with
538
539 @example
540 git-format-patch -n
541 @end example
542
543 where n an integer, normally 1.  This will create a
544 patch file for all the locally committed files which
545 differ from master.  The patch file can be found in
546 [path]/Git and will have a name formed from n and the
547 commit message.
548
549 @subsection Resolving merge conflicts
550
551 As soon as you have committed a changed file your
552 local branch has diverged from master, and will
553 remain diverged until your changes have been committed
554 in master.  Similarly, if a new commit has been made
555 to master by someone else, your branch is divergent.
556 You can detect a divergent branch my clicking on
557
558 @example
559 Repository -> Visualise all branch history
560 @end example
561
562 This opens up a very useful new window called @q{gitk}.
563
564 If the diagram at top left of the resulting window
565 does not show your branch on a single node at the
566 top your branch has diverged from master.  This is
567 quite normal if files you have modified yourself
568 have not yet been committed to master, or if files
569 have been modified and committed by others since
570 your last merge.
571
572 If a file being merged from master differs from
573 one you have modified in a way that cannot be resolved
574 automatically by git, Merge will report a Conflict
575 which you must resolve by editing the file to create the
576 version you wish to keep.
577
578 This could happen if the person updating master
579 for you has added some changes of his own before
580 committing your changes to master, or if someone
581 else has updated the same parent file as you at
582 the same time.
583
584 Open the file in your editor and look for sections which
585 are delimited with
586
587 [to be completed when I next have a merge conflict to be
588 sure I give the right instructions  -td]
589
590