]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/contributor/source-code.itexi
Issue 2100: Explanation of branches for CG
[lilypond.git] / Documentation / contributor / source-code.itexi
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3
4 @node Working with source code
5 @chapter Working with source code
6
7 @warning{New contributors should read @ref{Quick start}, and in
8 particular @ref{Using lily-git}, instead of this chapter.}
9
10 Advanced contributors will find this material quite useful,
11 particularly if they are working on major new features.
12
13 @menu
14 * Manually installing lily-git.tcl::
15 * Starting with Git::
16 * Basic Git procedures::
17 * Advanced Git procedures::
18 * Git on Windows::
19 * Repository directory structure::
20 * Other Git documentation::
21 @end menu
22
23
24 @node Manually installing lily-git.tcl
25 @section Manually installing lily-git.tcl
26
27 We have created an easy-to-use GUI to simplify git for new
28 contributors.  If you are comfortable with the command-line, then
29 skip ahead to @ref{Starting with Git}.
30
31 @warning{These instructions are only for people who are @emph{not}
32 using @ref{Lilydev}.}
33
34 @c there's some duplication in this section with stuff covered in
35 @c Quick Start, but moving it into a macro inside included/ would
36 @c be getting a bit icky.  -gp
37
38 @enumerate
39 @item
40 If you haven't already, download and install Git.
41
42 @itemize
43
44 @item Windows users: download the @code{.exe} file labeled
45 @qq{Full installer for official Git} from:
46
47 @example
48 @uref{http://code.google.com/p/msysgit/downloads/list}
49 @end example
50
51 @item Other operating systems: either install @command{git} with
52 your package manager, or download it from the @qq{Binaries}
53 section of:
54
55 @example
56 @uref{http://git-scm.com/download}
57 @end example
58
59 @end itemize
60
61
62 @item
63 Download the @command{lily-git.tcl} script from:
64
65 @c don't change the cgit link below to gitweb; gitweb uses
66 @c long filenames like "scripts_auxiliar_lily-git.tcl"
67
68 @smallexample
69 @uref{http://git.sv.gnu.org/cgit/lilypond.git/plain/scripts/auxiliar/lily-git.tcl}
70 @end smallexample
71
72 @item
73 To run the program from the command line, navigate to the
74 directory containing @command{lily-git.tcl} and enter:
75
76 @example
77 wish lily-git.tcl
78 @end example
79
80 @item
81 Click on the @qq{Get source} button.
82
83 This will create a directory called @file{lilypond-git/} within
84 your home directory, and will download the source code into that
85 directory (around 150@tie{}Mb).  When the process is finished, the
86 @qq{Command output} window will display @qq{Done}, and the button
87 label will change to say @qq{Update source}.
88
89 @item
90 Navigate to the @file{lilypond-git/} directory to view the source
91 files.
92
93 @end enumerate
94
95 @warning{Throughout the rest of this manual, most command-line
96 input should be entered from @file{~/lilypond-git/}.  This is
97 referred to as the @emph{top source directory}.}
98
99 Further instructions are in @ref{Daily use of lily-git.tcl}.
100
101
102 @node Starting with Git
103 @section Starting with Git
104
105 Using the Git program directly (as opposed to using the
106 @command{lily-git.tcl} GUI) allows you to have much greater control
107 over the contributing process.  You should consider using Git if
108 you want to work on complex projects, or if you want to work on
109 multiple projects concurrently.
110
111
112 @menu
113 * Setting up::
114 * Git for the impatient::
115 * Downloading remote branches::
116 @end menu
117
118
119 @node Setting up
120 @subsection Setting up
121
122 @warning{These instructions assume that you are using the
123 command-line version of Git 1.5 or higher.  Windows users should
124 skip to @ref{Git on Windows}.}
125
126 @menu
127 * Installing Git::
128 * Initializing a repository::
129 * Configuring Git::
130 @end menu
131
132
133 @node Installing Git
134 @unnumberedsubsubsec Installing Git
135
136 If you are using a Unix-based machine, the easiest way to download
137 and install Git is through a package manager such as @command{rpm}
138 or @command{apt-get} -- the installation is generally automatic.
139 The only required package is (usually) called @command{git-core},
140 although some of the auxiliary @command{git@var{*}} packages are
141 also useful (such as @command{gitk}).
142
143 Alternatively, you can visit the Git website
144 (@uref{http://git-scm.com/}) for downloadable binaries and
145 tarballs.
146
147
148 @node Initializing a repository
149 @unnumberedsubsubsec Initializing a repository
150
151 Once Git is installed, get a copy of the source code:
152
153 @example
154 git clone git://git.sv.gnu.org/lilypond.git ~/lilypond-git
155 @end example
156
157 The above command will put the it in @file{~/lilypond-git}, where
158 @code{~} represents your home directory.
159
160 @subsubheading Technical details
161
162 This creates (within the @file{~/lilypond-git/} directory) a
163 subdirectory called @file{.git/}, which Git uses to keep track of
164 changes to the repository, among other things.  Normally you don't
165 need to access it, but it's good to know it's there.
166
167
168 @node Configuring Git
169 @unnumberedsubsubsec Configuring Git
170
171 @warning{Throughout the rest of this manual, all command-line
172 input should be entered from the top directory of the Git
173 repository being discussed (eg. @file{~/lilypond-git/}).  This is
174 referred to as the @emph{top source directory}.}
175
176 Before working with the copy of the main LilyPond repository, you
177 should configure some basic settings with the
178 @command{git@tie{}config} command.  Git allows you to set both
179 global and repository-specific options.
180
181 To configure settings that affect all repositories, use the
182 @option{--global} command line option.  For example, the first
183 two options that you should always set are your @var{name} and
184 @var{email}, since Git needs these to keep track of commit
185 authors:
186
187 @example
188 git config --global user.name "@var{John Smith}"
189 git config --global user.email @var{john@@example.com}
190 @end example
191
192 To configure Git to use colored output where possible, use:
193
194 @example
195 git config --global color.ui auto
196 @end example
197
198 The text editor that opens when using @command{git@tie{}commit}
199 can also be changed.  If none of your editor-related environment
200 variables are set ($GIT_EDITOR, $VISUAL, or $EDITOR), the default
201 editor is usually @command{vi} or @command{vim}.  If you're not
202 familiar with either of these, you should probably change the
203 default to an editor that you know how to use.  For example, to
204 change the default editor to @command{nano}, enter:
205
206 @example
207 git config --global core.editor @var{nano}
208 @end example
209
210 Finally, and in some ways most importantly, let's make sure that
211 we know what branch we're on.  If you're not using lilydev, add
212 this to your @file{~/.bashrc}:
213
214 @verbatim
215 export PS1="\u@\h \w\$(__git_ps1)$ "
216 @end verbatim
217
218 If you are not using lilydev, you may need to install the
219 additional @code{git-completion} package, but it is definitely
220 worth it.
221
222
223 @subsubheading Technical details
224
225 Git stores the information entered with
226 @command{git@tie{}config@tie{}--global} in the file
227 @file{.gitconfig}, located in your home directory.  This file can
228 also be modified directly, without using
229 @command{git@tie{}config}.  The @file{.gitconfig} file generated
230 by the above commands would look like this:
231
232 @example
233 [user]
234         name = John Smith
235         email = john@@example.com
236 [color]
237         ui = auto
238 [core]
239         editor = nano
240 @end example
241
242 Using the @command{git@tie{}config} command @emph{without} the
243 @option{--global} option configures repository-specific settings,
244 which are stored in the file @file{.git/config}.  This file is
245 created when a repository is initialized (using
246 @command{git@tie{}init}), and by default contains these lines:
247
248 @example
249 [core]
250         repositoryformatversion = 0
251         filemode = true
252         bare = false
253         logallrefupdates = true
254 @end example
255
256 However, since different repository-specific options are
257 recommended for different development tasks, it is best to avoid
258 setting any now.  Specific recommendations will be mentioned later
259 in this manual.
260
261
262 @node Git for the impatient
263 @subsection Git for the impatient
264
265 @advanced{The intent of this subsection is to get you working on lilypond as
266 soon as possible.  If you want to learn about git, go read
267 @ref{Other Git documentation}.
268 @*
269 Also, these instructions are designed to eliminate the most common
270 problems we have found in using git.  If you already know git and
271 have a different way of working, great!  Feel free to ignore the
272 advice in this subsection.}
273
274
275 Ok, so you've been using @command{lily-git.tcl} for a while, but
276 it's time to take the next step.  Since our review process delays
277 patches by 60-120 hours, and you want to be able to work on other
278 stuff while your previous work is getting reviewed, you're going
279 to use @strong{branches}.
280
281 You can think of a branch as being a separate copy of the source
282 code.  But don't worry about it.
283
284 @subsubheading Start work: make a new branch
285
286 Let's pretend you want to add a section to the Contributor's Guide
287 about using branches.
288
289 Start by updating the repository, then making a new branch.  Call
290 the branch anything you want as long as the name starts with
291 @code{dev/}.  Branch names that don't begin with @code{dev/} are
292 reserved for special things in lilypond.
293
294 @example
295 git checkout master
296 git pull -r origin master
297 git branch dev/cg
298 @end example
299
300 @subsubheading Switch to that branch
301
302 Nothing has happened to the files yet.  Let's change into the new
303 branch.  You can think of this as @qq{loading a file}, although in
304 this case it's really @qq{loading a directory and subdirectories
305 full of files}.
306
307 @example
308 git checkout dev/cg
309 @end example
310
311 Your prompt now shows you that you're on the other branch:
312
313 @example
314 gperciva@@lilydev:~/lilypond-git (dev/cg)$ 
315 @end example
316
317 To be able to manage multiple lilypond issues at once, you'll need to switch
318 branches.  You should have each lilypond issue on a separate branch.
319 Switching branches is easy:
320
321 @example
322 git checkout master
323 git checkout origin/staging
324 git checkout origin/release/unstable
325 git checkout dev/cg
326 @end example
327
328 Branches that begin with @code{origin/} are part of the remote repository,
329 rather than your local repository, so when you check them out you get a 
330 temporary local branch.  You should never make changes directly on a
331 branch beginning with @code{origin/}.  You get changes into the remote
332 repository by making them in local branches, and then pushing them to
333 @code{origin/staging} as described below. 
334
335 @subsubheading Make your changes
336
337 Edit files, then commit them.
338
339 @example
340 git commit -a
341 @end example
342
343
344 Remember how I said that switching to a branch was like
345 @qq{loading a directory}?  Well, you've just @qq{saved a
346 directory}, so that you can @qq{load} it later.
347
348 @advanced{If you have used @command{cvs} or @command{svn}, you may
349 be very confused: those programs use @qq{commit} to mean
350 @qq{upload my changes to the shared source repository}.
351 Unfortunately, just to be different, @w{@command{git commit}}
352 means @qq{save my changes to the files}.}
353
354 When you create a new file, you need to add it to git, then commit it:
355
356 @example
357 git add input/regression/avoid-crash-on-condition.ly
358 git commit -a
359 @end example
360
361
362 Edit more files.  Commit them again.  Edit yet more files, commit
363 them again.  Go eat dinner.  Switch to @code{master} so you can
364 play with the latest changes from other developers.  Switch back
365 to your branch and edit some more.  Commit those changes.
366
367 At this stage, don't worry about how many commits you have.
368
369
370 @subsubheading Save commits to external files
371
372 Branches are nerve-wracking until you get used to them.  You can
373 save your hard work as individual @file{.patch} files.  Be sure to
374 commit your chages first.
375
376 @example
377 git commit -a
378 git format-patch master
379 @end example
380
381 I personally have between 4 and 20 of those files saved in a
382 special folder at any point in time.  Git experts might laugh as
383 that behavior, but I feel a @emph{lot} better knowing that I've
384 got those backups.
385
386
387 @subsubheading Prepare your branch for review
388
389 After committing, you can update your branch with the latest master:
390
391 @example
392 git commit -a
393 git checkout master
394 git pull -r origin master
395 git checkout dev/cg
396 git rebase master
397 @end example
398
399
400 Due to the speed of lilypond development, sometimes
401 @code{master} has changed so much that your branch can no
402 longer be applied to it.  In that happens, you will have a merge
403 conflict.  Stop for a moment to either cry or have a stiff drink,
404 then proceed to @ref{Merge conflicts}.
405
406
407 @subsubheading Upload your branch
408
409 Finally, you're finished your changes.  Time to upload for review.
410 Make sure that you're on your branch, then upload:
411
412 @example
413 git checkout dev/cg
414 git-cl upload master
415 @end example
416
417
418 @subsubheading Wait for reviews
419
420 While you're waiting for a countdown and reviews, go back to
421 master, make a @code{dev/doc-beams} branch, and start adding doc
422 suggestions from issue 12345 from the tracker.  Or make a
423 @code{dev/page-breaks} and fix bug in page breaking.  Or whatever.
424 Don't worry, your @code{dev/cg} is safe.
425
426
427 @subsubheading Combining commits (optional unless you have broken commits)
428
429 Does the history of your branch look good?
430
431 @example
432 gitk
433 @end example
434
435 If you have a lot of commits on your branch, you might want to
436 combine some of them.  Alternately, you may like your commits, but
437 want to edit the commit messages.
438
439 @example
440 git rebase -i master
441 @end example
442
443 Follow instructions on the screen.
444
445 @warning{This step gives you the power to completely lose your
446 work.  Make a backup of your commits by saving them to
447 @file{.patch} files before playing with this.  If you do lose
448 your work, don't despair.  You can get it back by using @code{git reflog}.
449 The use of @code{git reflog} is not covered here.}
450
451 @warning{If any of the commits on your branch represent partial work that will
452 not pass @var{make && make doc}, you @strong{must} squash these 
453 commits into a working commit.  Otherwise, your push will break staging
454 and will not be able to be merged to master.  In general, you will
455 be safer to have one commit per push.}
456
457
458 @subsubheading Push to staging
459
460 When you've got the coveted @code{Patch-push} status, time to
461 prepare your upload:
462
463 @example
464 git fetch
465 git rebase origin/staging dev/cg~0
466 gitk HEAD 
467 @end example
468
469 @warning{Do not skip the @command{gitk} step; a quick 5-second
470 check of the visual history can save a great deal of frustration
471 later on.  You should see a set of your commits that are ahead of
472 @code{origin/staging}, with no label for the top commit -- only a
473 SHA1 id.}
474
475 @warning{If @code{origin/staging} and @code{origin/master} are the
476 same commit, your branch (@code{dev/cg} in the example) will also
477 be at the top of the @code{gitk} tree.  This is normal.}
478
479 If everything looks good, push it:
480
481 @example
482 git push origin HEAD:staging
483 @end example
484
485 Then change back to your working branch:
486
487 @example
488 git checkout dev/cg
489 @end example
490
491 @warning{It is a best practice to avoid rebasing any of your branches
492 to @code{origin/staging}.  If @code{origin/staging} is broken, it
493 will be deleted and rebuilt.  If you have rebased one of your branches
494 to @code{origin/staging}, the broken commits can end up in your branch.
495 The commands given above do the rebase on a temporary branch, and avoid
496 changing your working branch.}
497
498
499 @subsubheading Delete your branch (safe)
500
501 After a few hours, if there's nothing wrong with your branch, it
502 should be automatically moved to @code{origin/master}.  Update,
503 then try removing your branch:
504
505 @example
506 git checkout master
507 git pull -r origin master
508 git branch -d dev/cg
509 @end example
510
511 The last command will fail if the contents of @code{dev/cg} are
512 not present in @code{origin/master}.
513
514
515 @subsubheading Delete your branch (UNSAFE)
516
517 @c don't give explicit commands here -- this is too dangerous to copy and paste
518 Sometimes everything goes wrong.  If you want to remove a branch even though 
519 it will cause your work to be lost (that is, if the contents of @code{dev/cg}
520 are @strong{not} present in master), follow the instructions in @qq{Delete
521 your branch (safe)}, but replace the @code{-d} on the final line with 
522 a @code{-D}.
523
524
525 @node Downloading remote branches
526 @subsection Downloading remote branches
527
528
529 @menu
530 * Organization of remote branches::
531 * LilyPond repository sources::
532 * Downloading individual branches::
533 * Downloading all remote branches::
534 * Other branches::
535 @end menu
536
537
538 @node Organization of remote branches
539 @unnumberedsubsubsec Organization of remote branches
540
541
542 The main LilyPond repository is organized into @emph{branches} to
543 facilitate development.  These are often called @emph{remote}
544 branches to distinguish them from @emph{local} branches you might
545 create yourself (see @ref{Using local branches}).
546
547 The @code{master} branch contains all the source files used to
548 build LilyPond, which includes the program itself (both stable and
549 development releases), the documentation (and its translations),
550 and the website.  Generally, the @code{master} branch is expected
551 to compile successfully.
552
553 The @code{lilypond/translation} branch is a side branch that
554 allows translators to work without needing to worry about
555 compilation problems.  Periodically, the Translation Meister
556 (after verifying that it doesn't break compilation), will
557 @emph{merge} this branch back into @code{master} to incorporate
558 recent translations.  Similarly, the @code{master} branch is
559 usually merged into the @code{lilypond/translation} branch after
560 significant changes to the English documentation.  See
561 @ref{Translating the documentation} for details.
562
563
564 @node LilyPond repository sources
565 @unnumberedsubsubsec LilyPond repository sources
566
567
568 The recommended source for downloading a copy of the main
569 repository is:
570
571 @example
572 git://git.sv.gnu.org/lilypond.git
573 @end example
574
575 However, if your internet router filters out connections using the
576 GIT protocol, or if you experience difficulty connecting via GIT,
577 you can try these other sources:
578
579 @example
580 ssh://git.sv.gnu.org/srv/git/lilypond.git
581 http://git.sv.gnu.org/r/lilypond.git
582 @end example
583
584 The SSH protocol can only be used if your system is properly set
585 up to use it.  Also, the HTTP protocol is slowest, so it should
586 only be used as a last resort.
587
588
589 @node Downloading individual branches
590 @unnumberedsubsubsec Downloading individual branches
591
592
593 Once you have initialized an empty Git repository on your system
594 (see @ref{Initializing a repository}), you can download a remote
595 branch into it.  Make sure you know which branch you want to start
596 with.
597
598 To download the @code{master} branch, enter the following:
599
600 @example
601 git remote add -ft master -m master \
602   origin git://git.sv.gnu.org/lilypond.git/
603 @end example
604
605 To download the @code{lilypond/translation} branch, enter:
606
607 @example
608 git remote add -ft lilypond/translation -m \
609   lilypond/translation origin git://git.sv.gnu.org/lilypond.git/
610 @end example
611
612 The @command{git@tie{}remote@tie{}add} process could take up to
613 ten minutes, depending on the speed of your connection.  The
614 output will be something like this:
615
616 @example
617 Updating origin
618 remote: Counting objects: 235967, done.
619 remote: Compressing objects: 100% (42721/42721), done.
620 remote: Total 235967 (delta 195098), reused 233311 (delta 192772)
621 Receiving objects: 100% (235967/235967), 68.37 MiB | 479 KiB/s, done.
622 Resolving deltas: 100% (195098/195098), done.
623 From git://git.sv.gnu.org/lilypond
624  * [new branch]      master     -> origin/master
625 From git://git.sv.gnu.org/lilypond
626  * [new tag]         flower/1.0.1 -> flower/1.0.1
627  * [new tag]         flower/1.0.10 -> flower/1.0.10
628 â‹®
629  * [new tag]         release/2.9.6 -> release/2.9.6
630  * [new tag]         release/2.9.7 -> release/2.9.7
631 @end example
632
633 When @command{git@tie{}remote@tie{}add} is finished, the remote
634 branch should be downloaded into your repository---though not yet
635 in a form that you can use.  In order to browse the source code
636 files, you need to @emph{create} and @emph{checkout} your own
637 local branch.  In this case, however, it is easier to have Git
638 create the branch automatically by using the @command{checkout}
639 command on a non-existent branch.  Enter the following:
640
641 @example
642 git checkout -b @var{branch} origin/@var{branch}
643 @end example
644
645 @noindent
646 where @code{@var{branch}} is the name of your tracking branch,
647 either @code{master} or @code{lilypond/translation}.
648
649 Git will issue some warnings; this is normal:
650
651 @example
652 warning: You appear to be on a branch yet to be born.
653 warning: Forcing checkout of origin/master.
654 Branch master set up to track remote branch master from origin.
655 Already on 'master'
656 @end example
657
658 By now the source files should be accessible---you should be able
659 to edit any files in the @file{lilypond-git/} directory using a
660 text editor of your choice.  But don't start just yet!  Before
661 editing any source files, learn how to keep your changes organized
662 and prevent problems later---read @ref{Basic Git procedures}.
663
664 @subsubheading Technical Details
665
666 The @command{git@tie{}remote@tie{}add} command should add some
667 lines to your local repository's @file{.git/config} file:
668
669 @example
670 [remote "origin"]
671         url = git://git.sv.gnu.org/lilypond.git/
672         fetch = +refs/heads/master:refs/remotes/origin/master
673 @end example
674
675
676 @node Downloading all remote branches
677 @unnumberedsubsubsec Downloading all remote branches
678
679
680 To download all remote branches at once, you can @command{clone}
681 the entire repository:
682
683 @example
684 git clone git://git.sv.gnu.org/lilypond.git
685 @end example
686
687
688 @node Other branches
689 @unnumberedsubsubsec Other branches
690
691 Most contributors will never need to touch the other branches.  If
692 you wish to do so, you will need more familiarity with Git; please
693 see @ref{Other Git documentation}.
694
695 @itemize
696 @item @code{dev/XYZ}:
697 These branches are for individual developers.  They store code
698 which is not yet stable enough to be added to the @code{master}
699 branch.
700
701 @item @code{stable/XYZ}:
702 The branches are kept for archival reasons.
703
704 @end itemize
705
706 Another item of interest might be the Grand Unified Builder, our
707 cross-platform building tool.  Since it is used by projects as
708 well, it is not stored in our gub repository.  For more info, see
709 @uref{http://lilypond.org/gub}.  The git location is
710 @uref{http://github.com/janneke/gub}.
711
712
713 @node Basic Git procedures
714 @section Basic Git procedures
715
716
717 @menu
718 * The Git contributor's cycle::
719 * Pulling and rebasing::
720 * Using local branches::
721 * Commits and patches::
722 @end menu
723
724
725 @node The Git contributor's cycle
726 @subsection The Git contributor's cycle
727
728
729 Here is a simplified view of the contribution process on Git:
730
731 @enumerate
732 @item
733 Update your local repository by @emph{pulling} the most recent
734 updates from the remote repository.
735
736 @item
737 Edit source files within your local repository's @emph{working
738 directory}.
739
740 @item
741 @emph{Commit} the changes you've made to a local @emph{branch}.
742
743 @item
744 Generate a @emph{patch} to share your changes with the developers.
745 @end enumerate
746
747
748 @node Pulling and rebasing
749 @subsection Pulling and rebasing
750
751
752 When developers push new patches to the @code{git.sv.gnu.org}
753 repository, your local repository is @strong{not} automatically
754 updated.  It is important to keep your repository up-to-date by
755 periodically @emph{pulling} the most recent @emph{commits} from
756 the remote branch.  Developers expect patches to be as current as
757 possible, since outdated patches require extra work before they
758 can be used.
759
760 Occasionally you may need to rework some of your own modifications
761 to match changes made to the remote branch (see @ref{Resolving
762 conflicts}), and it's considerably easier to rework things
763 incrementally.  If you don't update your repository along the way,
764 you may have to spend a lot of time resolving branch conflicts and
765 reconfiguring much of the work you've already done.
766
767 Fortunately, Git is able to resolve certain types of branch
768 conflicts automatically with a process called @emph{rebasing}.
769 When rebasing, Git tries to modify your old commits so they appear
770 as new commits (based on the latest updates).  For a more involved
771 explanation, see the @command{git-rebase} man page.
772
773 To pull without rebasing (recommended for translators), use the
774 following command:
775
776 @example
777 git pull    # recommended for translators
778 @end example
779
780 If you're tracking the remote @code{master} branch, you should add
781 the @option{-r} option (short for @option{--rebase}) to keep commits
782 on your local branch current:
783
784 @example
785 git pull -r # use with caution when translating
786 @end example
787
788 If you don't edit translated documentation and don't want to type
789 @option{-r} every time, configure the master branch to rebase by
790 default with this command:
791
792 @example
793 git config branch.master.rebase true
794 @end example
795
796 If pull fails because of a message like
797
798 @example
799 error: Your local changes to 'Documentation/learning/tutorial.itely'
800 would be overwritten by merge.  Aborting.
801 @end example
802
803 @noindent
804 or
805
806 @example
807 Documentation/learning/tutorial.itely: needs update
808 refusing to pull with rebase: your working tree is not up-to-date
809 @end example
810
811 @noindent
812 it means that you have modified some files in you working tree
813 without committing changes (see @ref{Commits and patches}); you
814 can use the @command{git@tie{}stash} command to work around this:
815
816 @example
817 git stash      # save uncommitted changes
818 git pull -r    # pull using rebase (translators omit "-r")
819 git stash pop  # reapply previously saved changes
820 @end example
821
822 Note that @command{git@tie{}stash@tie{}pop} will try to apply a
823 patch, and this may create a conflict.  If this happens, see
824 @ref{Resolving conflicts}.
825
826 TODO: I think the next paragraph is confusing.  Perhaps prepare
827 the reader for new terms `committish' and `head'?  -mp
828
829 @warning{translators and documentation editors, if you have
830 changed committishes in the head of translated files using commits
831 you have not yet pushed to @code{git.sv.gnu.org}, please do not
832 rebase.  If you want to avoid wondering whether you should rebase
833 each time you pull, please always use committishes from master
834 and/or lilypond/translation branch on @code{git.sv.gnu.org}, which
835 in particular implies that you must push your changes to
836 documentation except committishes updates (possibly after having
837 rebased), then update the committishes and push them.}
838
839 TODO: when committishes automatic conditional update have been
840 tested and documented, append the following to the warning above:
841 Note that using update-committishes make target generally touches
842 committishes.
843
844 @subsubheading Technical details
845
846 The @command{git@tie{}config} command mentioned above adds the
847 line @code{rebase = true} to the master branch in your local
848 repository's @file{.git/config} file:
849
850 @example
851 [branch "master"]
852         remote = origin
853         merge = refs/heads/master
854         rebase = true
855 @end example
856
857
858 @node Using local branches
859 @subsection Using local branches
860
861
862 @menu
863 * Creating and removing branches::
864 * Listing branches and remotes::
865 * Checking out branches::
866 * Merging branches::
867 @end menu
868
869
870 @node Creating and removing branches
871 @unnumberedsubsubsec Creating and removing branches
872
873
874 Local branches are useful when you're working on several different
875 projects concurrently.  To create a new branch, enter:
876
877 @example
878 git branch @var{name}
879 @end example
880
881 To delete a branch, enter:
882
883 @example
884 git branch -d @var{name}
885 @end example
886
887 Git will ask you for confirmation if it sees that data would be
888 lost by deleting the branch.  Use @option{-D} instead of @option{-d}
889 to bypass this.  Note that you cannot delete a branch if it is
890 currently checked out.
891
892
893 @node Listing branches and remotes
894 @unnumberedsubsubsec Listing branches and remotes
895
896 You can get the exact path or URL of all remote branches by
897 running:
898
899 @example
900 git remote -v
901 @end example
902
903 To list Git branches on your local repositories, run
904
905 @example
906 git branch     # list local branches only
907 git branch -r  # list remote branches
908 git branch -a  # list all branches
909 @end example
910
911
912 @node Checking out branches
913 @unnumberedsubsubsec Checking out branches
914
915 To know the currently checked out branch, i.e. the branch whose
916 source files are present in your working tree, read the first line
917 of the output of
918
919 @example
920 git status
921 @end example
922
923 @noindent
924 The currently checked out branch is also marked with an asterisk
925 in the output of @command{git branch}.
926
927 You can check out another branch @code{@var{other_branch}}, i.e.
928 check out @code{@var{other_branch}} to the working tree, by
929 running
930
931 @example
932 git checkout @var{other_branch}
933 @end example
934
935 Note that it is possible to check out another branch while having
936 uncommitted changes, but it is not recommended unless you know
937 what you are doing; it is recommended to run @command{git status}
938 to check this kind of issue before checking out another branch.
939
940 @node Merging branches
941 @unnumberedsubsubsec Merging branches
942
943 To merge branch @code{@var{foo}} into branch @code{@var{bar}},
944 i.e. to @qq{add} all changes made in branch @code{@var{foo}} to
945 branch @code{@var{bar}}, run
946
947 @example
948 git checkout @var{bar}
949 git merge @var{foo}
950 @end example
951
952 If any conflict happens, see @ref{Resolving conflicts}.
953
954 There are common usage cases for merging: as a translator, you
955 will often want to merge @code{master} into
956 @code{lilypond/translation}; on the other hand, the Translations
957 meister wants to merge @code{lilypond/translation} into
958 @code{master} whenever he has checked that
959 @code{lilypond/translation} builds successfully.
960
961
962 @node Commits and patches
963 @subsection Commits and patches
964
965
966 @menu
967 * Understanding commits::
968 * Making commits::
969 * Commit messages::
970 * Making patches::
971 * Uploading a patch for review::
972 @end menu
973
974
975 @node Understanding commits
976 @unnumberedsubsubsec Understanding commits
977
978 Technically, a @emph{commit} is a single point in the history of a
979 branch, but most developers use the term to mean a @emph{commit
980 object}, which stores information about a particular revision.  A
981 single commit can record changes to multiple source files, and
982 typically represents one logical set of related changes (such as a
983 bug-fix).  You can list the ten most recent commits in your
984 current branch with this command:
985
986 @example
987 git log -10 --oneline
988 @end example
989
990 If you're using an older version of Git and get an @q{unrecognized
991 argument} error, use this instead:
992
993 @example
994 git log -10 --pretty=oneline --abbrev-commit
995 @end example
996
997 More interactive lists of the commits on the remote @code{master}
998 branch are available at
999 @uref{http://git.sv.gnu.org/gitweb/?p=lilypond.git;a=shortlog} and
1000 @uref{http://git.sv.gnu.org/cgit/lilypond.git/log/}.
1001
1002
1003 @node Making commits
1004 @unnumberedsubsubsec Making commits
1005
1006
1007 Once you have modified some source files in your working
1008 directory, you can make a commit with the following procedure:
1009
1010 @enumerate
1011 @item
1012 Make sure you've configured Git properly (see @ref{Configuring
1013 Git}).  Check that your changes meet the requirements described in
1014 @ref{Code style} and/or @ref{Documentation policy}.  For advanced
1015 edits, you may also want to verify that the changes don't break
1016 the compilation process.
1017
1018 @item
1019 Run the following command:
1020
1021 @example
1022 git status
1023 @end example
1024
1025 @noindent
1026 to make sure you're on the right branch, and to see which files
1027 have been modified, added or removed, etc.  You may need to tell
1028 Git about any files you've added by running one of these:
1029
1030 @example
1031 git add @var{file}  # add untracked @var{file} individually
1032 git add .     # add all untracked files in current directory
1033 @end example
1034
1035 @noindent
1036 After @command{git@tie{}add}, run @command{git@tie{}status} again
1037 to make sure you got everything.  You may also need to modify
1038 @file{GNUmakefile}.
1039
1040 @item
1041 Preview the changes about to be committed (to make sure everything
1042 looks right) with:
1043
1044 @example
1045 git diff HEAD
1046 @end example
1047
1048 @noindent
1049 The @code{HEAD} argument refers to the most recent commit on the
1050 currently checked-out branch.
1051
1052 @item
1053 Generate the commit with:
1054
1055 @example
1056 git commit -a
1057 @end example
1058
1059 @noindent
1060 The @option{-a} is short for @option{--all} which includes modified
1061 and deleted files, but only those newly created files that have
1062 previously been added.
1063
1064 @end enumerate
1065
1066
1067 @node Commit messages
1068 @unnumberedsubsubsec Commit messages
1069
1070
1071 When you run the @command{git@tie{}commit@tie{}-a} command, Git
1072 automatically opens the default text editor so you can enter a
1073 @emph{commit message}.  If you find yourself in a foreign editing
1074 environment, you're probably in @command{vi} or @command{vim}.  If
1075 you want to switch to an editor you're more familiar with, quit by
1076 typing @code{:q!} and pressing @code{<Enter>}.  See
1077 @ref{Configuring Git} for instructions on changing the default
1078 editor.
1079
1080 In any case, Git will open a text file for your commit message
1081 that looks like this:
1082
1083 @example
1084
1085 # Please enter the commit message for your changes.  Lines starting
1086 # with '#' will be ignored, and an empty message aborts the commit.
1087 # On branch master
1088 # Changes to be committed:
1089 #   (use "git reset HEAD <file>..." to unstage)
1090 #
1091 #       modified:   working.itexi
1092 #
1093 @end example
1094
1095 Your commit message should begin with a one-line summary
1096 describing the change (no more than 50 characters long), and if
1097 necessary a blank line followed by several lines giving the
1098 details:
1099
1100 @c $ git log -1 --pretty=medium 4d6f1e5
1101 @example
1102 Doc: add Baerenreiter and Henle solo cello suites
1103
1104 Added comparison of solo cello suite engravings to new essay with
1105 high-res images, fixed cropping on Finale example.
1106 @end example
1107
1108 Commit messages often start with a short prefix describing the
1109 general location of the changes.  If a commit affects the
1110 documentation in English (or in several languages simultaneously)
1111 the commit message should be prefixed with @qq{Doc:@tie{}}.  If
1112 the commit affects only one of the translations, the commit
1113 message should be prefixed with @qq{Doc-@var{**}:@tie{}}, where
1114 @var{**} is the two-letter language code.  Commits that affect the
1115 website should use @qq{Web:@tie{}} for English, and
1116 @qq{Web-@var{**}:@tie{}} for the other languages.  Also, changes
1117 to a single file are often prefixed with the name of the file
1118 involved.  Visit the links listed in @ref{Understanding commits}
1119 for examples.
1120
1121
1122 @node Making patches
1123 @unnumberedsubsubsec Making patches
1124
1125 If you want to share your changes with other contributors and
1126 developers, you need to generate @emph{patches} from your commits.
1127 We prefer it if you follow the instructions in
1128 @ref{Uploading a patch for review}.  However, we present an
1129 alternate method here.
1130
1131 You should always run @command{git@tie{}pull@tie{}-r} (translators
1132 should leave off the @option{-r}) before doing this to ensure that
1133 your patches are as current as possible.
1134
1135 Once you have made one or more commits in your local repository,
1136 and pulled the most recent commits from the remote branch, you can
1137 generate patches from your local commits with the command:
1138
1139 @example
1140 git format-patch origin
1141 @end example
1142
1143 The @code{origin} argument refers to the remote tracking branch at
1144 @code{git.sv.gnu.org}.  This command generates a separate patch
1145 for each commit that's in the current branch but not in the remote
1146 branch.  Patches are placed in the current working directory and
1147 will have names that look something like this:
1148
1149 @example
1150 0001-Doc-Fix-typos.patch
1151 0002-Web-Remove-dead-links.patch
1152 â‹®
1153 @end example
1154
1155 Send an email (must be less than 64 KB) to
1156 @email{lilypond-devel@@gnu.org} briefly explaining your work, with
1157 the patch files attached.  Translators should send patches to
1158 @email{translations@@lilynet.net}.  After your patches are
1159 reviewed, the developers may push one or more of them to the main
1160 repository or discuss them with you.
1161
1162
1163 @node Uploading a patch for review
1164 @unnumberedsubsubsec Uploading a patch for review
1165
1166 Any non-trivial change should be uploaded to our @qq{Rietveld}
1167 code review website:
1168
1169 @example
1170 @uref{http://codereview.appspot.com/}
1171 @end example
1172
1173 @subsubheading @command{git-cl} install
1174
1175 LilyDev users should skip over these @q{install} instructions.
1176
1177 @enumerate
1178
1179 @item
1180 Install @command{git-cl} by entering:
1181
1182 @example
1183 git clone https://github.com/gperciva/git-cl.git
1184 @end example
1185
1186 If that command fails for some reason, try this instead:
1187
1188 @example
1189 git clone git://github.com/gperciva/git-cl.git
1190 @end example
1191
1192 @item
1193 Add the @file{git-cl/} directory to your PATH,
1194 or create a symbolic link to the @command{git-cl}
1195 and @command{upload.py} scripts in one of your PATH
1196 directories (such as @file{$HOME/bin}).
1197
1198 In Ubuntu (and Lilydev), you can add directories to PATH
1199 by adding this line to a hidden file @file{.bashrc},
1200 located in your home directory:
1201
1202 @example
1203 PATH=~/type-here-directory-containing-git-cl:"$@{PATH@}"
1204 @end example
1205
1206 @end enumerate
1207
1208 @subsubheading @command{git-cl} configuration
1209
1210 LilyDev users should perform these @q{configuration} instructions.
1211
1212 @enumerate
1213 @item
1214 You must have a google account; please create one if you do not
1215 have one already.
1216
1217 Note that a google account does not need to be a gmail account; you can
1218 use any email address for your google account when you sign up.
1219
1220 @item
1221 Move into the top source directory and then configure @command{git
1222 cl} with the following commands.  If you do not understand any
1223 question, just answer with a newline (CR).
1224
1225 @example
1226 cd $HOME/lilypond-git/
1227 git cl config
1228 @end example
1229
1230 The @qq{CC list} question should be answered with:
1231
1232 @example
1233 lilypond-devel@@gnu.org
1234 @end example
1235
1236 @end enumerate
1237
1238 @subsubheading Uploading patch set
1239
1240 @warning{Unless you are familiar with branches, only work on one
1241 set of changes at once.}
1242
1243 There are two methods, depending on your git setup.
1244
1245 @itemize
1246 @item
1247 @strong{Master branch}: (easy option, and used in @command{lily-git.tcl})
1248
1249 If you added your patch to @code{master}, then:
1250
1251 @example
1252 git pull -r
1253 git cl upload origin/master
1254 @end example
1255
1256 If you have git push ability, make sure that you @emph{remove}
1257 your patch (with @command{git rebase} or @command{git reset})
1258 before pushing other stuff.
1259
1260 @c don't make this one an @example; we don't want to make it easy
1261 @c for people to use this accidently
1262 Notifications of patches are automatically added to our issue
1263 tracker to reduce the chance of patches getting lost.  To suppress
1264 this (not recommended), add the @code{-n / --no-code-issue}
1265 option.
1266
1267 @item
1268 @strong{Separate branch}: (complicated option)
1269
1270 Ensure your changes are committed in a separate branch, which
1271 should differ from the reference branch to be used by just the
1272 changes to be uploaded.  If the reference branch is to be
1273 origin/master, ensure this is up-to-date.  If necessary, use git
1274 rebase to rebase the branch containing the changes to the head of
1275 origin/master.  Finally, check out branch with the changes and
1276 enter the command:
1277
1278 @example
1279 git cl upload <reference SHA1 ID>
1280 @end example
1281
1282 @noindent
1283 where <reference SHA1 ID> is the SHA1 ID of the commit to be used
1284 as a reference source for the patch.  Generally, this will be the
1285 SHA1 ID of origin/master, and in that case the command:
1286
1287 @example
1288 git cl upload origin/master
1289 @end example
1290
1291 @noindent
1292 can be used.
1293
1294 @end itemize
1295
1296 After prompting for your Google email address and password, the
1297 patch set will be posted to Rietveld, and you will be given a URL
1298 for your patch.
1299
1300 @warning{Some installations of git-cl fail when uploading a patch
1301 with certain filename extensions.  If this happens, it can
1302 generally be fixed by editing the list of exceptions at top of
1303 @file{git-cl.py}.}
1304
1305 @subsubheading Announcing your patch set
1306
1307 You should then announce the patch by logging into the code review
1308 issue webpage and using @qq{Publish + Mail Comments} to add a
1309 (mostly bogus) comment to your issue.  The text of your comment
1310 will be sent to our developer mailing list.
1311
1312 @warning{There is no automatic notification of a new patch; you
1313 must add a comment yourself.}
1314
1315 @subsubheading Revisions
1316
1317 As revisions are made in response to comments, successive patch sets
1318 for the same issue can be uploaded by reissuing the git-cl command
1319 with the modified branch checked out.
1320
1321 Sometimes in response to comments on revisions, the best way to
1322 work may require creation of a new branch in git.  In order to
1323 associate the new branch with an existing Rietveld issue,
1324 the following command can be used:
1325
1326 @example
1327 git cl issue issue-number
1328 @end example
1329
1330 @noindent
1331 where @code{issue-number} is the number of the existing Rietveld
1332 issue.
1333
1334 @subsubheading Resetting git cl
1335
1336 If @command{git cl} becomes confused, you can @qq{reset} it by
1337 running:
1338
1339 @example
1340 git cl issue 0
1341 @end example
1342
1343 @subsubheading Wait for a countdown
1344
1345 Your patch will be available for reviews for the next few hours or
1346 days.  Three times a week, patches with no known problems are
1347 gathered into a @qq{patch countdown} and their status changed to
1348 @code{patch-countdown}.  The countdown is a 48-hour waiting period
1349 in which any final reviews or complaints should be made.
1350
1351 During the countdown, your patch may be set to
1352 @code{patch-needs_work}, indicating that you should fix something
1353 (or at least discuss why the patch needs no modification).  If no
1354 problems are found, the patch will be set to @code{patch-push}.
1355
1356 Once a patch has @code{patch-push}, it should be sent to your
1357 mentor for uploading.  If you have git push ability, look at
1358 @ref{Pushing to staging}.
1359
1360
1361 @node Advanced Git procedures
1362 @section Advanced Git procedures
1363
1364
1365 @warning{This section is not necessary for normal contributors;
1366 these commands are presented for information for people interested
1367 in learning more about git.}
1368
1369 It is possible to work with several branches on the same local Git
1370 repository; this is especially useful for translators who may have
1371 to deal with both @code{lilypond/translation} and a stable branch,
1372 e.g. @code{stable/2.12}.
1373
1374 Some Git commands are introduced first, then a workflow with
1375 several Git branches of LilyPond source code is presented.
1376
1377
1378 @menu
1379 * Merge conflicts::
1380 * Advanced Git concepts::
1381 * Resolving conflicts::
1382 * Reverting all local changes::
1383 * Working with remote branches::
1384 * Git log::
1385 * Applying remote patches::
1386 * Sending and receiving patches via email::
1387 * Cleaning up multiple patches::
1388 * Commit access::
1389 * Pushing to staging::
1390 @end menu
1391
1392
1393 @node Merge conflicts
1394 @subsection Merge conflicts
1395
1396 To be filled in later, and/or moved to a different section.  I
1397 just wanted to make sure that I had a stub ready somewhere.
1398
1399
1400 @node Advanced Git concepts
1401 @subsection Advanced Git concepts
1402
1403
1404 A bit of Git vocabulary will be explained below.  The following is
1405 only introductory; for a better understanding of Git concepts, you
1406 may wish to read @ref{Other Git documentation}.
1407
1408 The @code{git@tie{}pull@tie{}origin} command above is just a
1409 shortcut for this command:
1410
1411 @example
1412 git pull git://git.sv.gnu.org/lilypond.git/ @var{branch}:origin/@var{branch}
1413 @end example
1414
1415 @noindent
1416 where @code{@var{branch}} is typically @code{master} or
1417 @code{lilypond/translation}; if you do not know or remember, see
1418 @ref{Downloading remote branches} to remember which commands you
1419 issued or which source code you wanted to get.
1420
1421 A @emph{commit} is a set of changes made to the sources; it also
1422 includes the committish of the parent commit, the name and e-mail
1423 of the @emph{author} (the person who wrote the changes), the name
1424 and e-mail of the @emph{committer} (the person who brings these
1425 changes into the Git repository), and a commit message.
1426
1427 A @emph{committish} is the SHA1 checksum of a commit, a number
1428 made of 40 hexadecimal digits, which acts as the internal unique
1429 identifier for this commit.  To refer to a particular revision,
1430 don't use vague references like the (approximative) date, simply
1431 copy and paste the committish.
1432
1433 A @emph{branch} is nothing more than a pointer to a particular
1434 commit, which is called the @emph{head} of the branch; when
1435 referring to a branch, one often actually thinks about its head
1436 and the ancestor commits of the head.
1437
1438 Now we will explain the two last commands you used to get the
1439 source code from Git---see @ref{Downloading individual branches}.
1440
1441 @example
1442 git remote add -ft @var{branch} -m @var{branch} \
1443   origin git://git.sv.gnu.org/lilypond.git/
1444
1445 git checkout -b @var{branch} origin/@var{branch}
1446 @end example
1447
1448 The @command{git@tie{}remote} has created a branch called
1449 @code{origin/@var{branch}} in your local Git repository.  As this
1450 branch is a copy of the remote branch web from git.sv.gnu.org
1451 LilyPond repository, it is called a @emph{remote branch}, and is
1452 meant to track the changes on the branch from git.sv.gnu.org: it
1453 will be updated every time you run
1454 @command{git@tie{}pull@tie{}origin} or
1455 @command{git@tie{}fetch@tie{}origin}.
1456
1457 The @command{git@tie{}checkout} command has created a branch named
1458 @code{@var{branch}}.  At the beginning, this branch is identical
1459 to @code{origin/@var{branch}}, but it will differ as soon as you
1460 make changes, e.g. adding newly translated pages or editing some
1461 documentation or code source file.  Whenever you pull, you merge
1462 the changes from @code{origin/@var{branch}} and
1463 @code{@var{branch}} since the last pulling.  If you do not have
1464 push (i.e. @qq{write}) access on git.sv.gnu.org, your
1465 @code{@var{branch}} will always differ from
1466 @code{origin/@var{branch}}.  In this case, remember that other
1467 people working like you with the remote branch @code{@var{branch}}
1468 of git://git.sv.gnu.org/lilypond.git/ (called
1469 @code{origin/@var{branch}} on your local repository) know nothing
1470 about your own @code{@var{branch}}: this means that whenever you
1471 use a committish or make a patch, others expect you to take the
1472 latest commit of @code{origin/@var{branch}} as a reference.
1473
1474 Finally, please remember to read the man page of every Git command
1475 you will find in this manual in case you want to discover
1476 alternate methods or just understand how it works.
1477
1478
1479 @node Resolving conflicts
1480 @subsection Resolving conflicts
1481
1482
1483 Occasionally an update may result in conflicts -- this happens
1484 when you and somebody else have modified the same part of the same
1485 file and git cannot figure out how to merge the two versions
1486 together.  When this happens, you must manually merge the two
1487 versions.
1488
1489 If you need some documentation to understand and resolve
1490 conflicts, see paragraphs @emph{How conflicts are presented} and
1491 @emph{How to resolve conflicts} in @command{git merge} man page.
1492
1493 If all else fails, you can follow the instructions in
1494 @ref{Reverting all local changes}.  Be aware that this eliminates
1495 any changes you have made!
1496
1497
1498 @node Reverting all local changes
1499 @subsection Reverting all local changes
1500
1501 Sometimes git will become hopelessly confused, and you just want
1502 to get back to a known, stable state.  This command destroys any
1503 local changes you have made in the currently checked-out branch,
1504 but at least you get back to the current online version:
1505
1506 @example
1507 git reset --hard origin/master
1508 @end example
1509
1510
1511 @node Working with remote branches
1512 @subsection Working with remote branches
1513
1514
1515 @subsubheading Fetching new branches from git.sv.gnu.org
1516
1517 To fetch and check out a new branch named @code{@var{branch}} on
1518 git.sv.gnu.org, run from top of the Git repository
1519
1520 @example
1521 git config --add remote.origin.fetch \
1522   +refs/heads/@var{branch}:refs/remotes/origin/@var{branch}
1523
1524 git checkout --track -b @var{branch} origin/@var{branch}
1525 @end example
1526
1527 After this, you can pull @code{@var{branch}} from git.sv.gnu.org
1528 with:
1529
1530 @example
1531 git pull
1532 @end example
1533
1534 Note that this command generally fetches all branches you added
1535 with @command{git@tie{}remote@tie{}add} (when you initialized the
1536 repository) or @command{git@tie{}config@tie{}--add}, i.e. it
1537 updates all remote branches from remote @code{origin}, then it
1538 merges the remote branch tracked by the current branch into the
1539 current branch.  For example, if your current branch is
1540 @code{master}, @code{origin/master} will be merged into
1541 @code{master}.
1542
1543
1544 @subsubheading Local clones, or having several working trees
1545
1546 If you play with several Git branches, e.g. @code{master},
1547 @code{lilypond/translation}, @code{stable/2.12}), you may want to
1548 have one source and build tree for each branch; this is possible
1549 with subdirectories of your local Git repository, used as local
1550 cloned subrepositories.  To create a local clone for the branch
1551 named @code{@var{branch}}, run
1552
1553 @example
1554 git checkout @var{branch}
1555 git clone -lsn . @var{subdir}
1556 cd @var{subdir}
1557 git reset --hard
1558 @end example
1559
1560 Note that @code{@var{subdir}} must be a directory name which does
1561 not already exist.  In @code{@var{subdir}}, you can use all Git
1562 commands to browse revisions history, commit and uncommit changes;
1563 to update the cloned subrepository with changes made on the main
1564 repository, cd into @code{@var{subdir}} and run
1565 @command{git@tie{}pull}; to send changes made on the subrepository
1566 back to the main repository, run @command{git@tie{}push} from
1567 @code{@var{subdir}}.  Note that only one branch (the currently
1568 checked out branch) is created in the subrepository by default; it
1569 is possible to have several branches in a subrepository and do
1570 usual operations (checkout, merge, create, delete...) on these
1571 branches, but this possibility is not detailed here.
1572
1573 When you push @code{@var{branch}} from @code{@var{subdir}} to the
1574 main repository, and @code{@var{branch}} is checked out in the
1575 main repository, you must save uncommitted changes (see
1576 @command{git@tie{}stash}) and do
1577 @command{git@tie{}reset@tie{}--hard} in the main repository in
1578 order to apply pushed changes in the working tree of the main
1579 repository.
1580
1581
1582 @node Git log
1583 @subsection Git log
1584
1585
1586 The commands above don't only bring you the latest version of the
1587 sources, but also the full history of revisions (revisions, also
1588 called commits, are changes made to the sources), stored in the
1589 @file{.git} directory.  You can browse this history with
1590
1591 @example
1592 git log     # only shows the logs (author, committish and commit message)
1593 git log -p  # also shows diffs
1594 gitk        # shows history graphically
1595 @end example
1596
1597 @warning{The @code{gitk} command may require a separate
1598 @code{gitk} package, available in the appropriate distribution's
1599 repositories.}
1600
1601
1602 @node Applying remote patches
1603 @subsection Applying remote patches
1604
1605
1606 TODO: Explain how to determine if a patch was created with
1607 @code{git@tie{}format-patch}.
1608
1609 Well-formed git patches created with @code{git@tie{}format-patch}
1610 should be committed with the following command:
1611
1612 @example
1613 git am @var{patch}
1614 @end example
1615
1616 Patches created without @code{git@tie{}format-patch} can be
1617 applied in two steps.  The first step is to apply the patch to the
1618 working tree:
1619
1620 @example
1621 git apply @var{patch}
1622 @end example
1623
1624 @noindent
1625 The second step is to commit the changes and give credit to the
1626 author of the patch.  This can be done with the following command:
1627
1628 @example
1629 git commit -a --author="@var{John Smith} <@var{john@@example.com}>"
1630 @end example
1631
1632
1633 @node Sending and receiving patches via email
1634 @subsection Sending and receiving patches via email
1635
1636
1637 The default @code{x-diff} MIME type associated with patch files
1638 (i.e., files whose name ends in @code{.patch}) means that the
1639 encoding of line endings may be changed from UNIX to DOS format
1640 when they are sent as attachments.  Attempting to apply such an
1641 inadvertently altered patch will cause git to fail with a message
1642 about @q{whitespace errors}.
1643
1644 The solution to such problems is surprisingly simple---just change
1645 the default file extension of patches generated by git to end in
1646 @code{.txt}, for example:
1647
1648 @example
1649 git config format.suffix '.patch.txt'
1650 @end example
1651
1652 This should cause email programs to apply the correct base64
1653 encoding to attached patches.
1654
1655 If you receive a patch with DOS instead of UNIX line-endings, it
1656 can be converted back using the @code{dos2unix} utility.
1657
1658 Lots of useful information on email complications with patches is
1659 provided on the Wine wiki at
1660 @uref{http://wiki.winehq.org/GitWine}.
1661
1662
1663 @node Cleaning up multiple patches
1664 @subsection Cleaning up multiple patches
1665
1666 If you have been developing on your own branch for a while, you
1667 may have more commmits than is really sensible.  To revise your
1668 work and condense commits, use:
1669
1670 @example
1671 git rebase origin/master
1672 git rebase -i origin/master
1673 @end example
1674
1675 @warning{Be a bit cautious -- if you completely remove commits
1676 during the interactive session, you will... err... completely
1677 remove those commits.}
1678
1679
1680 @node Commit access
1681 @subsection Commit access
1682
1683 Most contributors are not able to commit patches directly to the
1684 main repository---only members of the LilyPond development team
1685 have @emph{commit access}.  If you are a contributor and are
1686 interested in joining the development team, contact the Project
1687 Manager through the mailing list
1688 (@email{lilypond-devel@@gnu.org}).  Generally, only contributors
1689 who have already provided a number of patches which have been
1690 pushed to the main repository will be considered for membership.
1691
1692 If you have been approved by the Project Manager, use the
1693 following procedure to obtain commit access:
1694
1695 @enumerate
1696 @item
1697 If you don't already have one, set up a Savannah user account at
1698 @uref{https://savannah.gnu.org/account/register.php}.  If your web
1699 browser responds with an @qq{untrusted connection} message when
1700 you visit the link, follow the steps for including the CAcert root
1701 certificate in your browser, given at
1702 @uref{http://savannah.gnu.org/tls/tutorial/}.
1703
1704 @warning{Savannah will silently put your username in lower-case --
1705 do not try to use capital letters.}
1706
1707
1708 @item
1709 After registering, if you are not logged in automatically, login
1710 at @uref{https://savannah.gnu.org/account/login.php}---this should
1711 take you to your @qq{my} page
1712 (@uref{https://savannah.gnu.org/my/}).
1713
1714
1715 @item
1716 Click on the @qq{My Groups} link to access the @qq{My Group
1717 Membership} page.  From there, find the @qq{Request for Inclusion}
1718 box and search for @qq{LilyPond}.  Among the search results, check
1719 the box labeled @qq{GNU LilyPond Music Typesetter} and write a
1720 brief (required) message for the Project Manager (@qq{Hey it's
1721 me!} should be fine).
1722
1723 Note that you will not have commit access until the Project
1724 Manager activates your membership.  Once your membership is
1725 activated, LilyPond should appear under the heading @qq{Groups I'm
1726 Contributor of} on your @qq{My Group Membership} page.
1727
1728
1729 @item
1730 Generate an SSH @q{rsa} key pair.  Enter the following at the
1731 command prompt:
1732
1733 @example
1734 ssh-keygen -t rsa
1735 @end example
1736
1737 When prompted for a location to save the key, press <ENTER> to
1738 accept the default location (@file{~/.ssh/id_rsa}).
1739
1740 Next you are asked to enter an optional passphrase.  On most
1741 systems, if you use a passphrase, you will likely be prompted for
1742 it every time you use @command{git@tie{}push} or
1743 @command{git@tie{}pull}.  You may prefer this since it can protect
1744 you from your own mistakes (like pushing when you mean to pull),
1745 though you may find it tedious to keep re-entering it.
1746
1747 You can change/enable/disable your passphrase at any time with:
1748
1749 @example
1750 ssh-keygen -f ~/.ssh/id_rsa -p
1751 @end example
1752
1753 Note that the GNOME desktop has a feature which stores your
1754 passphrase for you for an entire GNOME session.  If you use a
1755 passphrase to @qq{protect you from yourself}, you will want to
1756 disable this feature, since you'll only be prompted once.  Run the
1757 following command, then logout of GNOME and log back in:
1758
1759 @example
1760 gconftool-2 --set -t bool \
1761   /apps/gnome-keyring/daemon-components/ssh false
1762 @end example
1763
1764 After setting up your passphrase, your private key is saved as
1765 @file{~/.ssh/id_rsa} and your public key is saved as
1766 @file{~/.ssh/id_rsa.pub}.
1767
1768
1769 @item
1770 Register your public SSH @q{rsa} key with Savannah.  From the
1771 @qq{My Account Configuration} page, click on @qq{Edit SSH Keys},
1772 then paste the contents of your @file{~/.ssh/id_rsa.pub} file into
1773 one of the @qq{Authorized keys} text fields, and click
1774 @qq{Update}.
1775
1776 Savannah should respond with something like:
1777
1778 @example
1779 Success: Key #1 seen Keys registered
1780 @end example
1781
1782
1783 @item
1784 Configure Git to use the SSH protocol (instead of the GIT
1785 protocol).  From your local Git repository, enter:
1786
1787 @example
1788 git config remote.origin.url \
1789   ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond.git
1790 @end example
1791
1792 @noindent
1793 replacing @var{user} with your Savannah username.
1794
1795
1796 @item
1797 After your membership has been activated and you've configured Git
1798 to use SSH, test the connection with:
1799
1800 @example
1801 git pull --verbose
1802 @end example
1803
1804 SSH should issue the following warning:
1805
1806 @example
1807 The authenticity of host 'git.sv.gnu.org (140.186.70.72)' can't
1808 be established.
1809 RSA key fingerprint is
1810 80:5a:b0:0c:ec:93:66:29:49:7e:04:2b:fd:ba:2c:d5.
1811 Are you sure you want to continue connecting (yes/no)?
1812 @end example
1813
1814 Make sure the RSA key fingerprint displayed matches the one above.
1815 If it doesn't, respond @qq{no} and check that you configured Git
1816 properly in the previous step.  If it does match, respond
1817 @qq{yes}.  SSH should then issue another warning:
1818
1819 @example
1820 Warning: Permanently added 'git.sv.gnu.org,140.186.70.72' (RSA) to
1821 the list of known hosts.
1822 @end example
1823
1824 The list of known hosts is stored in the file
1825 @file{~/.ssh/known_hosts}.
1826
1827 At this point, you are prompted for your passphrase if you have
1828 one, then Git will attempt a pull.
1829
1830 If @command{git@tie{}pull@tie{}--verbose} fails, you should see
1831 error messages like these:
1832
1833 @example
1834 Permission denied (publickey).
1835 fatal: The remote end hung up unexpectedly
1836 @end example
1837
1838 If you get the above error, you may have made a mistake when
1839 registering your SSH key at Savannah.  If the key is properly
1840 registered, you probably just need to wait for the Savannah server
1841 to activate it.  It usually takes a few minutes for the key to be
1842 active after registering it, but if it still doesn't work after an
1843 hour, ask for help on the mailing list.
1844
1845 If @command{git@tie{}pull@tie{}--verbose} succeeds, the output
1846 will include a @q{From} line that shows @q{ssh} as the protocol:
1847
1848 @example
1849 From ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond
1850 @end example
1851
1852 If the protocol shown is not @q{ssh}, check that you configured
1853 Git properly in the previous step.
1854
1855
1856 @item
1857 Test your commit access with a dry run:
1858
1859 @warning{Do not push directly to master; instead, push to staging.
1860 See @ref{Pushing to staging}.}
1861
1862 @example
1863 git push --dry-run --verbose
1864 @end example
1865
1866 Note that recent versions of Git (Git 1.6.3 or later) will issue a
1867 big warning if the above command is used.  The simplest solution
1868 is to tell Git to push all matching branches by default:
1869
1870 @example
1871 git config push.default matching
1872 @end example
1873
1874 @noindent
1875 Then @code{git@tie{}push} should work as before.  For more
1876 details, consult the @code{git@tie{}push} man page.
1877
1878
1879 @item
1880 Repeat the steps from generating an RSA key through to testing
1881 your commit access, for each machine from which you will be
1882 making commits, or you may simply copy the files from your
1883 local @file{~/.ssh} folder to the same folder on the other
1884 machine.
1885
1886 @end enumerate
1887
1888 @subsubheading Technical details
1889
1890 @itemize
1891 @item
1892 On Firefox, to view or remove the CAcert root certificate, go to:
1893 Edit > Preferences > Advanced > Encryption > View Certificates >
1894 Authorities > Certificate Name > Root CA > CA Cert Signing
1895 Authority.
1896
1897 @item
1898 The @command{git@tie{}config} commands above should modify your
1899 local repository's @file{.git/config} file.  These lines:
1900
1901 @example
1902 [remote "origin"]
1903         url = git://git.sv.gnu.org/lilypond.git/
1904 @end example
1905
1906 @noindent
1907 should now be changed to:
1908
1909 @example
1910 [remote "origin"]
1911         url = ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond.git
1912 @end example
1913
1914 @noindent
1915 where @var{user} is your login name on Savannah.
1916
1917 @item
1918 Similarly, the
1919 @command{git@tie{}config@tie{}push.default@tie{}matching} command
1920 should add these lines to @file{.git/config}:
1921
1922 @example
1923 [push]
1924         default = matching
1925 @end example
1926 @end itemize
1927
1928 @knownissues
1929 Encryption protocols, including ssh, generally do not permit packet
1930 fragmentation to avoid introducing a point of insecurity.  This
1931 means that the maximum packet size must not exceed the smallest
1932 MTU (Maximum Transmission Unit) set in the routers along the path.
1933 This smallest MTU is determined by a procedure during call set-up
1934 which relies on the transmission over the path of ICMP packets.
1935 If any of the routers in the path block ICMP packets this mechanism
1936 fails, resulting in the possibility of packets being transmitted
1937 which exceed the MTU of one of the routers.  If this happens the
1938 packet is discarded, causing the ssh session to hang, timeout or
1939 terminate with the error message
1940
1941 @example
1942 ssh: connect to host <host ip addr> port 22: Bad file number
1943 fatal: The remote end hung up unexpectedly
1944 @end example
1945
1946 depending on precisely when in the proceedings the first large
1947 packet is transmitted.  Most routers on the internet have MTU
1948 set to 1500, but routers installed in homes to connect via
1949 broadband may use a slightly smaller MTU for efficient transmission
1950 over ATM.  If this problem is encountered a possible work-around is
1951 to set the MTU in the local router to 1500.
1952
1953
1954 @node Pushing to staging
1955 @subsection Pushing to staging
1956
1957 Do not push directly to the git @code{master} branch.  Instead,
1958 push to @code{staging}.
1959
1960 You will not see your patch on @code{origin/master} until some
1961 automatic tests have been run.  These tests are run every couple
1962 of hours; please wait at least 12 hours before wondering if your
1963 patch has been lost.  Note that you can check the commits on
1964 @code{origin/staging} by looking at the git web interface on
1965 savannah.
1966
1967 @subsubheading If your work is in a patch file
1968
1969 Assuming that your patch is in a file called
1970 @file{0001-my-patch.patch}, and you are currently on git master,
1971 do:
1972
1973 @example
1974 git checkout staging
1975 git pull -r
1976 git am 0001-my-patch.patch
1977 gitk
1978 git push origin staging
1979 git checkout master
1980 @end example
1981
1982 @warning{Do not skip the @command{gitk} step; a quick 5-second
1983 check of the visual history can save a great deal of frustration
1984 later on.  You should only see that @command{staging} is only 1
1985 commit ahead of @code{origin/staging}.}
1986
1987 @subsubheading If your work is in a branch
1988
1989 If you are working on branches and your work in is
1990 @code{my_branch_name}, then do:
1991
1992 @example
1993 git checkout staging
1994 git pull -r
1995 git merge my_branch_name
1996 gitk
1997 git push origin staging
1998 @end example
1999
2000 @warning{Do not skip the @command{gitk} step; a quick 5-second
2001 check of the visual history can save a great deal of frustration
2002 later on.  You should see that @code{staging} is only ahead of
2003 @code{origin/staging} by the commits from your branch.}
2004
2005
2006
2007 @node Git on Windows
2008 @section Git on Windows
2009
2010 @warning{We heavily recommend that development be done with our
2011 virtual machine @ref{Lilydev}.}
2012
2013 @c Some of this may duplicate stuff in other sections
2014 @c But it is probably best for windows users to have it all together
2015 @c If necessary, clear this up later  -td
2016
2017 TODO: Decide what to do with this...  Pare it down?  Move
2018 paragraphs next to analogous Unix instructions? -mp
2019
2020 @subsection Background to nomenclature
2021
2022 Git is a system for tracking the changes made to source files by a
2023 distributed set of editors.  It is designed to work without a
2024 master repository, but we have chosen to have a master repository
2025 for LilyPond files.  Editors hold a local copy of the master
2026 repository together with any changes they have made locally.
2027 Local changes are held in a local @q{branch}, of which there may
2028 be several, but these instructions assume you are using just one.
2029 The files visible in the local repository always correspond to
2030 those on the currently @q{checked out} local branch.
2031
2032 Files are edited on a local branch, and in that state the changes
2033 are said to be @q{unstaged}.  When editing is complete, the
2034 changes are moved to being @q{staged for commit}, and finally the
2035 changes are @q{committed} to the local branch.  Once committed,
2036 the changes (called a @q{commit}) are given a unique 40-digit
2037 hexadecimal reference number called the @q{Committish} or @q{SHA1
2038 ID} which identifies the commit to Git.  Such committed changes
2039 can be sent to the master repository by @q{pushing} them (if you
2040 have write permission) or by sending them by email to someone who
2041 has, either as a complete file or as a @q{diff} or @q{patch}
2042 (which send just the differences from the master repository).
2043
2044 @subsection Installing git
2045
2046 Obtain Git from
2047 @uref{http://code.google.com/p/msysgit/downloads/list} (note, not
2048 msysGit, which is for Git developers and not PortableGit, which is
2049 not a full git installation) and install it.
2050
2051 Note that most users will not need to install SSH.  That is not
2052 required until you have been granted direct push permissions to
2053 the master git repository.
2054
2055 Start Git by clicking on the desktop icon.  This will bring up a
2056 command line bash shell.  This may be unfamiliar to Windows users.
2057 If so, follow these instructions carefully.  Commands are entered
2058 at a $ prompt and are terminated by keying a newline.
2059
2060 @subsection Initialising Git
2061
2062 Decide where you wish to place your local Git repository, creating
2063 the folders in Windows as necessary.  Here we call the folder to
2064 contain the repository @code{[path]/Git}, but if you intend using
2065 Git for other projects a directory name like @code{lilypond-git}
2066 might be better.  You will need to have space for around
2067 100Mbytes.
2068
2069 Start the Git bash shell by clicking on the desk-top icon
2070 installed with Git and type
2071
2072 @example
2073 cd [path]/Git
2074 @end example
2075
2076 to position the shell at your new Git repository.
2077
2078 Note: if [path] contains folders with names containing spaces use
2079
2080 @example
2081 cd "[path]/Git"
2082 @end example
2083
2084 Then type
2085
2086 @example
2087 git init
2088 @end example
2089
2090 to initialize your Git repository.
2091
2092 Then type (all on one line; the shell will wrap automatically)
2093
2094 @example
2095 git remote add -ft master origin git://git.sv.gnu.org/lilypond.git
2096 @end example
2097
2098 to download the lilypond master files.
2099
2100 @warning{Be patient!  Even on a broadband connection this can take
2101 10 minutes or more.  Wait for lots of [new tag] messages and the $
2102 prompt.}
2103
2104 We now need to generate a local copy of the downloaded files in a
2105 new local branch.  Your local branch needs to have a name.  It is
2106 usual to call it @q{master} and we shall do that here.
2107
2108 To do this, type
2109
2110 @example
2111 git checkout -b master origin/master
2112 @end example
2113
2114 This creates a second branch called @q{master}.  You will see two
2115 warnings (ignore these), and a message advising you that your
2116 local branch @q{master} has been set up to track the remote
2117 branch.  You now have two branches, a local branch called
2118 @q{master}, and a tracking branch called @q{origin/master}, which
2119 is a shortened form of @q{remotes/origin/master}.
2120
2121 Return to Windows Explorer and look in your Git repository.  You
2122 should see lots of folders.  For example, the LilyPond
2123 documentation can be found in [path]/Git/Documentation/.
2124
2125 The Git bash shell is terminated by typing @code{exit} or by
2126 clicking on the usual Windows close-window widget.
2127
2128 @subsection Git GUI
2129
2130 Almost all subsequent work will use the Git Graphical User
2131 Interface, which avoids having to type command line commands.  To
2132 start Git GUI first start the Git bash shell by clicking on the
2133 desktop icon, and type
2134
2135 @example
2136 cd [path]/Git
2137 git gui
2138 @end example
2139
2140 The Git GUI will open in a new window.  It contains four panels
2141 and 7 pull-down menus.  At this stage do not use any of the
2142 commands under Branch, Commit, Merge or Remote.  These will be
2143 explained later.
2144
2145 The top panel on the left contains the names of files which you
2146 are in the process of editing (Unstaged Changes), and the lower
2147 panel on the left contains the names of files you have finished
2148 editing and have staged ready for committing (Staged Changes).  At
2149 present, these panels will be empty as you have not yet made any
2150 changes to any file.  After a file has been edited and saved the
2151 top panel on the right will display the differences between the
2152 edited file selected in one of the panels on the left and the last
2153 version committed on the current branch.
2154
2155 The panel at bottom right is used to enter a descriptive message
2156 about the change before committing it.
2157
2158 The Git GUI is terminated by entering CNTL-Q while it is the
2159 active window or by clicking on the usual Windows close-window
2160 widget.
2161
2162 @subsection Personalising your local git repository
2163
2164 Open the Git GUI, click on
2165
2166 @example
2167 Edit -> Options
2168 @end example
2169
2170 and enter your name and email address in the left-hand (Git
2171 Repository) panel.  Leave everything else unchanged and save it.
2172
2173 Note that Windows users must leave the default setting for line
2174 endings unchanged.  All files in a git repository must have lines
2175 terminated by just a LF, as this is required for Merge to work,
2176 but Windows files are terminated by CRLF by default.  The git
2177 default setting causes the line endings of files in a Windows git
2178 repository to be flipped automatically between LF and CRLF as
2179 required.  This enables files to be edited by any Windows editor
2180 without causing problems in the git repository.
2181
2182 @subsection Checking out a branch
2183
2184 At this stage you have two branches in your local repository,
2185 both identical.  To see them click on
2186
2187 @example
2188 Branch -> Checkout
2189 @end example
2190
2191 You should have one local branch called @q{master} and one
2192 tracking branch called @q{origin/master}.  The latter is your
2193 local copy of the @q{remotes/origin/master} branch in the master
2194 LilyPond repository.  The local @q{master} branch is where you
2195 will make your local changes.
2196
2197 When a particular branch is selected, i.e., checked out, the files
2198 visible in your repository are changed to reflect the state of the
2199 files on that branch.
2200
2201 @subsection Updating files from @q{remote/origin/master}
2202
2203 Before starting the editing of a file, ensure your local
2204 repository contains the latest version of the files in the remote
2205 repository by first clicking
2206
2207 @example
2208 Remote -> Fetch from -> origin
2209 @end example
2210
2211 @noindent
2212 in the Git GUI.
2213
2214 This will place the latest version of every file, including all
2215 the changes made by others, into the @q{origin/master} branch of
2216 the tracking branches in your git repository.  You can see these
2217 files by checking out this branch, but you must @emph{never} edit
2218 any files while this branch is checked out.  Check out your local
2219 @q{master} branch again.
2220
2221 You then need to merge these fetched files into your local
2222 @q{master} branch by clicking on
2223
2224 @example
2225 Merge -> Local Merge
2226 @end example
2227
2228 @noindent
2229 and if necessary select the local @q{master} branch.
2230
2231 Note that a merge cannot be completed if you have made any local
2232 changes which have not yet been committed.
2233
2234 This merge will update all the files in the @q{master} branch to
2235 reflect the current state of the @q{origin/master} branch.  If any
2236 of the changes conflict with changes you have made yourself
2237 recently you will be notified of the conflict (see below).
2238
2239 @subsection Editing files
2240
2241 First ensure your @q{master} branch is checked out, then simply
2242 edit the files in your local Git repository with your favourite
2243 editor and save them back there.  If any file contains non-ASCII
2244 characters ensure you save it in UTF-8 format.  Git will detect
2245 any changes whenever you restart Git GUI and the file names will
2246 then be listed in the Unstaged Changes panel.  Or you can click
2247 the Rescan button to refresh the panel contents at any time.  You
2248 may break off and resume editing any time.
2249
2250 The changes you have made may be displayed in diff form in the top
2251 right-hand panel of Git GUI by clicking on the file name shown in
2252 one of the left panels.
2253
2254 When your editing is complete, move the files from being Unstaged
2255 to Staged by clicking the document symbol to the left of each
2256 name.  If you change your mind it can be moved back by clicking on
2257 the ticked box to the left of the name.
2258
2259 Finally the changes you have made may be committed to your
2260 @q{master} branch by entering a brief message in the Commit
2261 Message box and clicking the Commit button.
2262
2263 If you wish to amend your changes after a commit has been made,
2264 the original version and the changes you made in that commit may
2265 be recovered by selecting
2266
2267 @example
2268 Commit -> Amend Last Commit
2269 @end example
2270
2271 @noindent
2272 or by checking the Amend Last Commit radio button at bottom right.
2273 This will return the changes to the Staged state, so further
2274 editing made be carried out within that commit.  This must only be
2275 done @emph{before} the changes have been Pushed or sent to your
2276 mentor for Pushing - after that it is too late and corrections
2277 have to be made as a separate commit.
2278
2279
2280 @subsection Sending changes to @q{remotes/origin/master}
2281
2282 If you do not have write access to @q{remotes/origin/master} you
2283 will need to send your changes by email to someone who does.
2284
2285 First you need to create a diff or patch file containing your
2286 changes.  To create this, the file must first be committed.  Then
2287 terminate the Git GUI.  In the git bash shell first cd to your Git
2288 repository with
2289
2290 @example
2291 cd [path]/Git
2292 @end example
2293
2294 if necessary, then produce the patch with
2295
2296 @example
2297 git format-patch origin
2298 @end example
2299
2300 This will create a patch file for all the locally committed files
2301 which differ from @q{origin/master}.  The patch file can be found
2302 in [path]/Git and will have a name formed from the commit message.
2303
2304 @subsection Resolving merge conflicts
2305
2306 As soon as you have committed a changed file your local
2307 @code{master} branch has diverged from @code{origin/master}, and
2308 will remain diverged until your changes have been committed in
2309 @code{remotes/origin/master} and Fetched back into your
2310 @code{origin/master} branch.  Similarly, if a new commit has been
2311 made to @code{remotes/origin/master} by someone else and Fetched,
2312 your local @code{master} branch is divergent.  You can detect a
2313 divergent branch by clicking on
2314
2315 @example
2316 Repository -> Visualise all branch history
2317 @end example
2318
2319 This opens up a very useful new window called @q{gitk}.  Use this
2320 to browse all the commits made by yourself and others.
2321
2322 If the diagram at top left of the resulting window does not show
2323 your @code{master} tag on the same node as the
2324 @code{remotes/origin/master} tag your branch has diverged from
2325 @code{origin/master}.  This is quite normal if files you have
2326 modified yourself have not yet been Pushed to
2327 @code{remotes/origin/master} and Fetched, or if files modified and
2328 committed by others have been Fetched since you last Merged
2329 @code{origin/master} into your local @code{master} branch.
2330
2331 If a file being merged from @code{origin/master} differs from one
2332 you have modified in a way that cannot be resolved automatically
2333 by git, Merge will report a Conflict which you must resolve by
2334 editing the file to create the version you wish to keep.
2335
2336 This could happen if the person updating
2337 @code{remotes/origin/master} for you has added some changes of his
2338 own before committing your changes to
2339 @code{remotes/origin/master}, or if someone else has changed the
2340 same file since you last fetched the file from
2341 @code{remotes/origin/master}.
2342
2343 Open the file in your editor and look for sections which are
2344 delimited with ...
2345
2346 [to be completed when I next have a merge conflict to be sure I
2347 give the right instructions  -td]
2348
2349
2350 @subsection Other actions
2351
2352 The instructions above describe the simplest way of using git on
2353 Windows.  Other git facilities which may usefully supplement these
2354 include
2355
2356 @itemize
2357 @item Using multiple local branches (Create, Rename, Delete)
2358 @item Resetting branches
2359 @item Cherry-picking commits
2360 @item Pushing commits to @w{remote/origin/master}
2361 @item Using gitk to review history
2362 @end itemize
2363
2364 Once familiarity with using git on Windows has been gained the
2365 standard git manuals can be used to learn about these.
2366
2367
2368 @node Repository directory structure
2369 @section Repository directory structure
2370
2371
2372 @c TODO: integrate the roadmap better
2373 @verbatiminclude ROADMAP
2374
2375
2376 @node Other Git documentation
2377 @section Other Git documentation
2378
2379 @itemize
2380 @item
2381 Official git man pages:
2382 @uref{http://www.kernel.org/pub/software/scm/git/docs/}
2383
2384 @item
2385 More in-depth tutorials: @uref{http://git-scm.com/documentation}
2386
2387 @item
2388 Book about git: @uref{http://progit.org/,Pro Git}
2389
2390 @item
2391 Github help: @uref{http://help.github.com/}
2392 (very highly recommended by Graham)
2393
2394 @end itemize
2395