]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/contributor/git-starting.itexi
Doc-de: updates from master to NR
[lilypond.git] / Documentation / contributor / git-starting.itexi
1 @c -*- coding: us-ascii; mode: texinfo; -*-
2 @node Starting with git
3 @chapter Starting with git
4
5 To complete or present in another form the introduction to Git usage
6 in this chapter, it may be a good idea to look for Git documentation
7 at @uref{http://git-scm.com/documentation},
8
9 @menu
10 * Getting the source code::     
11 * Updating the source code::    
12 * Sharing your changes::        
13 * Advanced git stuff::          
14 * Git on Windows::              
15 * Development inside VirtualBox (compiling on Windows)::  
16 @end menu
17
18
19 @node Getting the source code
20 @section Getting the source code
21
22 @menu
23 * Git introduction::            
24 * Git user configuration::      
25 * Main source code::            
26 * Documentation translations source code::  
27 * Other branches::              
28 * Other locations for git::     
29 @end menu
30
31 @node Git introduction
32 @subsection Git introduction
33
34 The source code is kept in a Git respository.  This allows us to
35 track changes to files, and for multiple people to work on the
36 same set of files efficiently.
37
38 After downloading the source code, it is important to update the
39 repository by @ref{Updating the source code}.
40
41 @warning{These instructions assume that you are using the
42 command-line version of Git 1.5 or higher.  Windows users should
43 skip to @ref{Git on Windows}.}
44
45 Some sections of this guide will redirect to specific Git man pages;
46 however, if you think you need to understand more of Git, you might want
47 to read the book @uref{http://progit.org/,Pro Git}.
48
49
50 @node Git user configuration
51 @subsection Git user configuration
52
53 Some useful cofiguration can be performed automatically; cut and
54 paste the following section:
55
56 @example
57 git config --global color.ui auto
58 git config --global branch.autosetuprebase always
59 @end example
60
61 To configure git to automatically use your name and email address
62 for commits and patches, edit the below lines by changing all the
63 @code{MY...} entries:
64
65 @example
66 git config --global user.name "MYNAME"
67 git config --global user.email MYEMAIL@@EXAMPLE.NET
68 @end example
69
70
71 @node Main source code
72 @subsection Main source code
73
74 To get the main source code and documentation,
75
76 @c WARNING: when updating the commands below, please
77 @c update the other flavors in the two next nodes
78 @c and in Introduction to Git concepts
79 @smallexample
80 mkdir lilypond; cd lilypond
81 git init-db
82 git remote add -f -t master -m master origin git://git.sv.gnu.org/lilypond.git/
83 git checkout -b master origin/master
84 @end smallexample
85
86
87 @node Documentation translations source code
88 @subsection Documentation translations source code
89
90 To translate the documentation (@emph{not} the website),
91 FIXME: when website is integrated, modify this.
92
93 @smallexample
94 mkdir lilypond-translation; cd lilypond-translation
95 git init-db
96 git remote add -f -t lilypond/translation -m lilypond/translation origin git://git.sv.gnu.org/lilypond.git/
97 git checkout -b lilypond/translation origin/lilypond/translation
98 @end smallexample
99
100
101 @node Other branches
102 @subsection Other branches
103
104 Most contributors will never need to touch the other branches.  If
105 you wish to do so, you will need more familiarity with git.
106
107 @itemize
108
109 @item @code{dev/XYZ}:
110 These branches are for individual developers.  They store code
111 which is not yet stable enough to be added to the @code{master}
112 branch.
113
114 @item @code{stable/XYZ}:
115 The branches are kept for archival reasons.
116
117 @end itemize
118
119 Another item of interest might be the Grand Unified Builder, our
120 cross-platform building tool.  Since it is used by projects as
121 well, it is not stored in our gub repository.  For more info, see
122 @uref{http://lilypond.org/gub}.  The git location is:
123
124 @example
125 http://github.com/janneke/gub
126 @end example
127
128
129 @node Other locations for git
130 @subsection Other locations for git
131
132 If you have difficulty connecting to most of the repositories
133 listed in earlier sections, try:
134
135 @example
136 http://git.sv.gnu.org/r/lilypond.git
137 git://git.sv.gnu.org/lilypond.git
138 ssh://git.sv.gnu.org/srv/git/lilypond.git
139 @end example
140
141 Using HTTP protocol is slowest, so it is not recommended unless both
142 SSH and Git protocols fail, which happens e.g. if you connect to
143 internet through a router that filters out Git and/or SSH connections.
144
145
146
147 @node Updating the source code
148 @section Updating the source code
149
150 @menu
151 * Importance of updating::      
152 * Update command::              
153 * Resolving conflicts::         
154 @end menu
155
156
157 @node Importance of updating
158 @subsection Importance of updating
159
160 In a large project like LilyPond, contributors sometimes edit the same
161 file at the same time.  As long as everybody updates their version of
162 the file with the most recent changes (@emph{pulling}), there are
163 generally no problems with this multiple-person editing.  However,
164 big problems can arise if you do not pull before attempting to
165 commit.  If this occurs, see @ref{Resolving conflicts}.
166
167
168 @node Update command
169 @subsection Updating command
170
171 Whenever you are asked to pull, it means you should update your
172 local copy of the repository with the changes made by others on
173 the remote @code{git.sv.gnu.org} repository:
174
175 @example
176 git pull -r
177 @end example
178
179 @noindent
180 The @code{-r} option is short for @code{--rebase}.  If you don't
181 want to type @code{-r} every time, add @code{rebase = true} to the
182 master branch in your @file{.git/config}, like so:
183
184 @example
185 [branch "master"]
186         remote = origin
187         merge = refs/heads/master
188         rebase = true
189 @end example
190
191 @warning{translators and documentation editors, if you have changed
192 committishes in the head of translated files using commits you have not
193 yet pushed to @code{git.sv.gnu.org}, please do not rebase.  If you want
194 to avoid wondering whether you should rebase each time you pull, please
195 always use committishes from master and/or lilypond/translation branch
196 on @code{git.sv.gnu.org}, which in particular implies that you must push
197 your changes to documentation except committishes updates (possibly
198 after having rebased), then update the committishes and push them.}
199
200 @c FIXME: when committishes automatic conditional update have been
201 @c tested and documented, append the following to the warning above:
202 @c Note that using update-committishes make target generally touches
203 @c committishes.
204
205
206 @node Resolving conflicts
207 @subsection Resolving conflicts
208
209 Occasionally an update may result in conflicts -- this happens
210 when you and somebody else have modified the same part of the same
211 file and git cannot figure out how to merge the two versions
212 together.  When this happens, you must manually merge the two
213 versions.
214
215 If you need some documentation to understand and resolve conflicts,
216 see paragraphs @emph{How conflicts are presented} and @emph{How to
217 resolve conflicts} in @command{git merge} man page.
218
219
220 @node Sharing your changes
221 @section Sharing your changes
222
223 @menu
224 * Producing a patch::           
225 * Committing directly::         
226 @end menu
227
228
229 @node Producing a patch
230 @subsection Producing a patch
231
232 Once you have finished editing your files, checked that your changes
233 meet the @ref{Code style}, and/or @ref{Documentation policy}, properly
234 set up your name and email in @ref{Git user configuration}, and
235 checked that the entire thing compiles, you may:
236
237 @example
238 git commit -a
239 git format-patch origin
240 @end example
241
242 The commit should include a brief message describing the change.
243 This consists of a one-line summary describing the change, and
244 if necessary a blank line followed by several lines giving the
245 details:
246
247 @example
248 Did household chores.
249
250 I hung up the wet laundry and then washed the car.  I also
251 vacuumed the floors, rinsed the dirty dishes, fed the cat, and
252 recalibrated the temporal flux machine.
253 @end example
254
255 If the change is to the documentation only then the one-line
256 summary should be prefixed with @qq{Docs: }.
257
258 If you added a file to the source code, you must add it to git
259 with:
260
261 @example
262 git add @var{FILENAME}
263 @end example
264
265 @noindent
266 (and possibly modify the @file{GNUmakefile})
267
268 These commands will produce one or more files named @file{0001-xyz},
269 @file{0002-abc}, etc. in the top directory of the git tree.  Send an
270 email to @email{lilypond-devel@@gnu.org} with these files attached, and
271 a developer will review and apply the patches to the main repository.
272 If your patch is some translation work, you may send it to
273 @email{translations@@lilynet.net} instead.
274
275
276 @node Committing directly
277 @subsection Committing directly
278
279 Most contributors do not have permission to commit directly.  If you do,
280 make sure you have set up your name and email in @ref{Git user
281 configuration}, then edit @file{.git/config}: change the line
282
283 @example
284 url = git://git.sv.gnu.org/lilypond.git/
285 @end example
286
287 @noindent
288 into
289
290 @example
291 url = ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond.git
292 @end example
293
294 @noindent
295 where @var{user} is your login name on Savannah.
296
297 If you have not already done so, you should generate and upload a
298 SSH key: open @uref{https://savannah.gnu.org/my/} in your browser,
299 go to @q{Account Configuration}, then to something like
300 @q{Edit SSH Keys}, and follow the instructions on that page.
301
302 You may then:
303
304 @example
305 git push origin
306 @end example
307
308 Note that recent versions of Git (Git 1.6.3 or later) will issue a
309 big warning if the above command is used.  The simplest solution
310 is to add a new section to @file{.git/config} that looks like
311 this:
312
313 @example
314 [push]
315         default = matching
316 @end example
317
318 @noindent
319 Then @code{git push origin} will work as before.  For more
320 details, consult the @code{git push} man page.
321
322
323 @node Advanced git stuff
324 @section Advanced git stuff
325
326 @warning{This section is not necessary for normal contributors;
327 these commands are presented for information for people interested
328 in learning more about git.}
329
330
331 It is possible to work with several branches on the same local Git
332 repository; this is especially useful for translators who may have to
333 deal with both @code{lilypond/translation} and a stable branch,
334 e.g. @code{stable/2.12}.
335
336 Some Git commands are introduced first, then a workflow with several
337 Git branches of LilyPond source code is presented.
338
339 @menu
340 * Introduction to Git concepts::  
341 * Git commands for managing several branches::  
342 * Working on LilyPond sources with several branches::  
343 * Git log::                     
344 * Applying git patches::        
345 * Reverting all local changes::  
346 @end menu
347
348
349 @node Introduction to Git concepts
350 @subsection Introduction to Git concepts
351
352 A bit of Git vocabulary will be explained below.  The following is
353 just introduction material; for better understanding of Git concepts,
354 you are invited to read further documentation, especially Git
355 Community Book at @uref{http://book.git-scm.com/}.
356
357 The @code{git pull origin} command above is just a shortcut for this
358 command:
359
360 @example
361 git pull git://git.sv.gnu.org/lilypond.git/ @var{branch}:origin/@var{branch}
362 @end example
363
364 @noindent
365 where @code{@var{branch}} is typically @code{master}, @code{web} or
366 @code{lilypond/translation}; if you do not know or remember, see
367 @ref{Getting the source code} to remember which commands you issued or
368 which source code you wanted to get.
369
370 A @emph{commit} is a set of changes made to the sources; it also
371 includes the committish of the parent commit, the name and e-mail of
372 the @emph{author} (the person who wrote the changes), the name and
373 e-mail of the @emph{committer} (the person who brings these changes
374 into the Git repository), and a commit message.
375
376 A @emph{committish} is the SHA1 checksum of a commit, a number made of
377 40 hexadecimal digits, which acts as the internal unique identifier
378 for this commit.  To refer to a particular revision, don't use vague
379 references like the (approximative) date, simply copy and paste the
380 committish.
381
382 A @emph{branch} is nothing more than a pointer to a particular commit,
383 which is called the @emph{head} of the branch; when referring to a
384 branch, one often acutally thinks about its head and the ancestor
385 commits of the head.
386
387 Now we will explain the two last commands you used to get the source
388 code from Git -- see @ref{Getting the source code}.
389
390 @example
391 git remote add -f -t @var{branch} -m @var{branch} origin git://git.sv.gnu.org/lilypond.git/
392 git checkout -b @var{branch} origin/@var{branch}
393 @end example
394
395 The @command{git remote} has created a branch called
396 @code{origin/@var{branch}} in your local Git repository.  As this
397 branch is a copy of the remote branch web from git.sv.gnu.org LilyPond
398 repository, it is called a @emph{remote branch}, and is meant to track
399 the changes on the branch from git.sv.gnu.org: it will be updated
400 every time you run @command{git pull origin} or @command{git fetch
401 origin}.
402
403 The @command{git checkout} command has created a branch named
404 @code{@var{branch}}.  At the beginning, this branch is identical to
405 @code{origin/@var{branch}}, but it will differ as soon as you make
406 changes, e.g. adding newly translated pages or editing some
407 documentation or code source file.  Whenever you pull, you merge the
408 changes from @code{origin/@var{branch}} and @code{@var{branch}} since
409 the last pulling.  If you do not have push (i.e. @qq{write}) access on
410 git.sv.gnu.org, your @code{@var{branch}} will always differ from
411 @code{origin/@var{branch}}.  In this case, remember that other people
412 working like you with the remote branch @code{@var{branch}} of
413 git://git.sv.gnu.org/lilypond.git/ (called @code{origin/@var{branch}}
414 on your local repository) know nothing about your own
415 @code{@var{branch}}: this means that whenever you use a committish or
416 make a patch, others expect you to take the latest commit of
417 @code{origin/@var{branch}} as a reference.
418
419 Finally, please remember to read the man page of every Git command you
420 will find in this manual in case you want to discover alternate
421 methods or just understand how it works.
422
423
424 @node Git commands for managing several branches
425 @subsection Git commands for managing several branches
426
427 @subsubheading Listing branches and remotes
428
429 You can get the exact path or URL of all remotes with
430 running
431
432 @example
433 git remote -v
434 @end example
435
436 To list Git branches on your local repositories, run
437
438 @example
439 git branch     # list local branches only
440 git branch -r  # list remote branches
441 git branch -a  # list all branches
442 @end example
443
444
445 @subsubheading Checking out branches
446
447 To know the currently checked out branch, i.e. the branch whose source
448 files are present in your working tree, read the first line of the
449 output of
450
451 @example
452 git status
453 @end example
454
455 @noindent
456 The currently checked out branch is also marked with an asterisk in
457 the output of @command{git branch}.
458
459 You can check out another branch @code{@var{other_branch}}, i.e. check
460 out @code{@var{other_branch}} to the working tree, by running
461
462 @example
463 git checkout @var{other_branch}
464 @end example
465
466 Note that it is possible to check out another branch while having
467 uncommitted changes, but it is not recommended unless you know what
468 you are doing; it is recommended to run @command{git status} to check
469 this kind of issue before checking out another branch.
470
471
472 @subsubheading Merging branches
473
474 To merge branch @code{@var{foo}} into branch @code{@var{bar}}, i.e. to
475 @qq{add} all changes made in branch @code{@var{foo}} to branch
476 @code{@var{bar}}, run
477
478 @example
479 git checkout @var{bar}
480 git merge @var{foo}
481 @end example
482
483 If any conflict happens, see @ref{Resolving conflicts}.
484
485 There are common usage cases for merging: as a translator, you will
486 often want to merge @code{master} into @code{lilypond/translation}; on
487 the other hand, the Translations meister wants to merge
488 @code{lilypond/translation} into @code{master} whenever he has checked
489 that @code{lilypond/translation} builds successfully.
490
491
492 @node Working on LilyPond sources with several branches
493 @subsection Working on LilyPond sources with several branches
494
495 @subsubheading Fetching new branches from git.sv.gnu.org
496
497 To fetch and check out a new branch named @code{@var{branch}} on
498 git.sv.gnu.org, run from top of the Git repository
499
500 @example
501 git config --add remote.origin.fetch +refs/heads/@var{branch}:refs/remotes/origin/@var{branch}
502 git checkout --track -b @var{branch} origin/@var{branch}
503 @end example
504
505 After this, you can pull @code{@var{branch}} from git.sv.gnu.org with
506
507 @example
508 git pull origin
509 @end example
510
511 Note that this command generally fetches all branches you added with
512 @command{git remote add} (when you initialized the repository) or
513 @command{git config --add}, i.e. it updates all remote branches from
514 remote @code{origin}, then it merges the remote branch tracked by
515 current branch into current branch.  For example, if your current
516 branch is @code{master} --- which is the case if you got the sources
517 with the commands described in @ref{Main source code} and did not
518 issue any @command{git checkout} command --- @code{origin/master} will
519 be merged into @code{master}.
520
521
522 @subsubheading Local clones, or having several working trees
523
524 If you play with several Git branches, e.g. @code{master},
525 @code{lilypond/translation}, @code{stable/2.12}), you may want to have
526 one source and build tree for each branch; this is possible with
527 subdirectories of your local Git repository, used as local cloned
528 subrepositories.  To create a local clone for the branch named
529 @code{@var{branch}}, run
530
531 @example
532 git checkout @var{branch}
533 git clone -l -s -n . @var{subdir}
534 cd @var{subdir}
535 git reset --hard
536 @end example
537
538 Note that @code{@var{subdir}} must be a directory name which does not
539 already exist.  In @code{@var{subdir}}, you can use all Git commands
540 to browse revisions history, commit and uncommit changes; to update
541 the cloned subrepository with changes made on the main repository, cd
542 into @code{@var{subdir}} and run @command{git pull}; to send changes
543 made on the subrepository back to the main repository, run
544 @command{git push} from @code{@var{subdir}}.  Note that only one
545 branch (the currently checked out branch) is created in the
546 subrepository by default; it is possible to have several branches in a
547 subrepository and do usual operations (checkout, merge, create,
548 delete...) on these branches, but this possibility is not detailed
549 here.
550
551 When you push @code{@var{branch}} from @code{@var{subdir}} to the main
552 repository, and @code{@var{branch}} is checked out in the main
553 repository, you must save uncommitted changes (see @command{git
554 stash}) and do @command{git reset --hard} in the main repository in
555 order to apply pushed changes in the working tree of the main
556 repository.
557
558
559 @node Git log
560 @subsection Git log
561
562 The commands above don't only bring you the latest version of the
563 sources, but also the full history of revisions (revisons, also
564 called commits, are changes made to the sources), stored in the
565 .git directory.  You can browse this history with
566
567 @example
568 git log     # only shows the logs (author, committish and commit message)
569 git log -p  # also shows diffs
570 gitk        # shows history graphically
571 @end example
572
573 @warning{The @code{gitk} command may require a separate @code{gitk} package,
574 available in the appropriate distribution's repositories.}
575
576
577 @node Applying git patches
578 @subsection Applying git patches
579
580 Well-formed git patches created with @code{git format-patch}
581 should be committed with the following command:
582
583 @example
584 git am @var{patch}
585 @end example
586
587 Patches created without @code{git format-patch} can be applied in
588 two steps.  The first step is to apply the patch to the working
589 tree:
590
591 @example
592 git apply @var{patch}
593 @end example
594
595 @noindent
596 The second step is to commit the changes and give credit to the
597 author of the patch.  This can be done with the following command:
598
599 @example
600 git commit -a --author="First Last <user@@example.net>"
601 @end example
602
603
604 @node Reverting all local changes
605 @subsection Reverting all local changes
606
607 Sometimes git will become hopelessly confused, and you just want
608 to get back to a known, stable state.  This command destroys any
609 local changes you have made, but at least you get back to the
610 current online version:
611
612 @example
613 git reset --hard origin/master
614 @end example
615
616
617 @node Git on Windows
618 @section Git on Windows
619
620 @c Some of this may duplicate stuff in other sections
621 @c Clear this up later  -td
622
623 @subsection Background to nomenclature
624
625 Git is a system for tracking the changes made to source files by
626 a distributed set of editors.  It is designed to work without a
627 master repository, but we have chosen to have a master respository
628 for LilyPond files.  Editors hold local copies of the master
629 repository together with any changes they have made locally.  Local
630 changes are held in a local @q{branch}, of which there may be
631 several, but these instructions assume you are using just one.  The
632 files visible in the local repository always correspond to those
633 on the currently @q{checked out} local branch.
634
635 Files are edited on a local branch, and in that state the
636 changes are said to be @q{unstaged}.  When editing is complete, the
637 changes are moved to being @q{staged for commit}, and finally the
638 changes are @q{committed} to the local branch.  Once
639 committed, the changes are given a unique reference number called the
640 @q{Committish} which identifies them to Git.  Such committed changes
641 can be sent to the master repository by @q{pushing} them (if you
642 have write permission) or by sending them by email to someone who
643 has, either complete or as a @q{diff} or @q{patch} (which send
644 just the differences from master).
645
646 @subsection Installing git
647
648 Obtain Git from
649 @uref{http://code.google.com/p/msysgit/downloads/list}
650 (note, not msysGit, which is for Git developers and not PortableGit,
651 which is not a full git installation) and
652 install it.
653
654 Note that most users will not need to install SSH.  That is not
655 required until you have been granted direct push permissions to
656 the master git repository.
657
658 Start Git by clicking on the desktop icon.
659 This will bring up a command line bash shell.  This may be
660 unfamiliar to Windows users.  If so, follow these
661 instructions carefully.  Commands are entered at a $ prompt
662 and are terminated by keying a newline.
663
664 @subsection Initialising Git
665
666 Decide where you wish to place your local Git repository,
667 creating the folders in Windows as necessary.  Here we
668 call the folder to contain the repository [path]/Git.
669 You will need to have space for around 150Mbytes.
670
671 Start the Git bash shell by clicking on the desk-top icon installed
672 with Git and type
673
674 @example
675 cd [path]/Git
676 @end example
677
678 to position the shell at your new Git repository.
679
680 Note: if [path] contains folders with names containing
681 spaces use
682
683 @example
684 cd "[path]/Git"
685 @end example
686
687 Then type
688
689 @example
690 git init
691 @end example
692
693 to initialize your Git repository.
694
695 Then type (all on one line; the shell will wrap automatically)
696
697 @example
698 git remote add -f -t master origin git://git.sv.gnu.org/lilypond.git
699 @end example
700
701 to download the lilypond master files.
702
703 @warning{Be patient!  Even on a broadband connection this can take
704 10 minutes or more.  Wait for lots of [new tag] messages
705 and the $ prompt.}
706
707 We now need to generate a local copy of the downloaded files
708 in a new local branch.  Your local branch needs to have a
709 name, here we call it @q{lily-local} - you may wish to make up
710 your own.
711
712 Then, finally, type
713
714 @example
715 git checkout -b lily-local origin/master
716 @end example
717
718 to create the lily-local branch containing the local copies of the
719 master files.  You will be advised your local branch has been set
720 up to track the remote branch.
721
722 Return to Windows Explorer and look in your Git repository.  You
723 should see lots of folders.  For example, the LilyPond documentation
724 can be found in Git/Documentation/user.
725
726 Terminate the Git bash shell by typing @code{exit}.
727
728 @subsection Git GUI
729
730 Almost all subsequent work will use the Git Graphical User
731 Interface, which avoids having to type command line
732 commands. To start Git GUI first start the Git bash shell by
733 clicking on the desktop icon, and type
734
735 @example
736 cd [path]/Git
737 git gui
738 @end example
739
740 The Git GUI will open in a new window.  It contains four panels
741 and 7 pull-down menus.  At this stage do not use any of the
742 commands under Branch, Commit, Merge or Remote.  These will
743 be explained later.
744
745 The two panels on the left contain the names of files which
746 you are in the process of editing (Unstaged Changes), and
747 files you have finished editing and have staged ready for
748 committing (Staged Changes).  At this stage these panels will
749 be empty as you have not yet made any changes to any file.
750 After a file has been edited and saved the top panel on the right
751 will display the differences between the edited file selected
752 in one of the panels on the left and the last version committed.
753
754 The final panel at bottom right is used to enter a descriptive
755 message about the change before committing it.
756
757 The Git GUI is terminated by entering CNTL-Q while it is the
758 active window or by clicking on the usual Windows close-window
759 widget.
760
761 @subsection Personalising your local git repository
762
763 Open the Git GUI, click on
764
765 @example
766 Edit -> Options
767 @end example
768
769 and enter your name and email address in the
770 left-hand (Git Repository) panel.  Leave everything
771 else unchanged and save it.
772
773 Note that Windows users must leave the default setting for line
774 endings unchanged.  All files in a git repository must have lines
775 terminated by just a LF, as this is required for Merge to work, but
776 Windows files are terminated by CRLF by default.  The git default
777 setting causes the line endings of files in a Windows git repository
778 to be flipped automatically between LF and CRLF as required.  This
779 enables files to be edited by any Windows editor without causing
780 problems in the git repository.
781
782 @subsection Checking out a branch
783
784 At this stage you have two branches in your local repository,
785 both identical.  To see them click on
786
787 @example
788 Branch -> Checkout
789 @end example
790
791 You should have one local branch called @w{lily-local} and one
792 tracking branch called @w{origin/master}.  The latter is your
793 local copy of the @w{remote/origin/master} branch in the master
794 LilyPond repository.  The @w{lily-local} branch is where you
795 will make your local changes.
796
797 When a particular branch is selected, i.e., checked out, the
798 files visible in your repository are changed to reflect the
799 state of the files on that branch.
800
801 @subsection Updating files from @w{remote/origin/master}
802
803 Before starting the editing of a file, ensure your local branches
804 contain the latest version in @w{remote/origin/master} by first
805 clicking
806
807 @example
808 Remote -> Fetch from -> origin
809 @end example
810
811 @noindent
812 in the Git GUI.
813
814 This will place the latest version of every file, including all the
815 changes made by others,
816 into the @q{origin/master} branch of the tracking branches
817 in your git repository.  You can see these files by checking
818 out this branch.  This will not affect any files you have
819 modified in your local branch.
820
821 You then need to merge these fetched files into your local
822 branch by clicking on
823
824 @example
825 Merge -> Local Merge
826 @end example
827
828 @noindent
829 and if necessary select the local branch into which the merge
830 is to be made.
831
832 Note that a merge cannot be completed if there are any local
833 uncommitted changes on the lily-local branch.
834
835 This will update all the files in that branch to reflect the
836 current state of the @w{origin/master} branch.  If any of the
837 changes conflict with changes you have made yourself recently
838 you will be notified of the conflict (see below).
839
840 @subsection Editing files
841
842 First ensure your lily-local branch is checked out, then
843 simply edit the files in your local Git repository with your
844 favourite editor and save them back there.  If any file contains
845 non-ASCII characters ensure you save it in UTF-8 format.  Git will
846 detect any changes whenever you restart Git GUI and the file names
847 will then be listed in the Unstaged Changes panel.
848 Or you can click the Rescan button to refresh the panel
849 contents at any time.  You may break off and resume at
850 editing any time.
851
852 The changes you have made may be displayed in diff form
853 in the top right-hand panel by clicking on the name in
854 Git GUI.
855
856 When your editing is complete, move the files from being
857 Unstaged to Staged by clicking the document symbol to
858 the left of each name.  If you change your mind it can
859 be moved back by clicking on the ticked box to the
860 left of the name.
861
862 Finally the changes you have made may be committed to
863 your lily-local branch by entering a brief message in
864 the Commit Message box and clicking the Commit button.
865
866 If you wish to amend your changes after a commit has been
867 made, the original version and the changes you made in that
868 commit may be recovered by selecting
869
870 @example
871 Commit -> Amend Last Commit
872 @end example
873
874 @noindent
875 or by checking the Amend Last Commit radio button at bottom left.
876 This will return the changes to the Staged state, so further
877 editing made be carried out within that commit.  This must only be
878 done @emph{before} the changes have been Pushed or sent to your
879 mentor for Pushing - after that it is too late and corrections
880 have to be made as a separate commit.
881
882
883 @subsection Sending changes to remote/origin/master
884
885 If you do not have write access to @w{remote/origin/master} you will
886 need to send your changes by email to someone who does.
887
888 First you need to create a diff or patch file containing
889 your changes.  To create this, the file must first be
890 committed.  Then terminate the Git GUI.  In the
891 git bash shell first cd to your Git repository with
892
893 @example
894 cd [path]/Git
895 @end example
896
897 if necessary, then produce the patch with
898
899 @example
900 git format-patch origin
901 @end example
902
903 This will create a patch file for all the locally committed files
904 which differ from @w{origin/master}.  The patch file can be found
905 in [path]/Git and will have a name formed from n and the commit
906 message.
907
908 @subsection Resolving merge conflicts
909
910 As soon as you have committed a changed file your local
911 branch has diverged from @w{origin/master}, and will
912 remain diverged until your changes have been committed
913 in @w{remote/origin/master} and Fetched back into your
914 @w{origin/master}.  Similarly, if a new commit has been made
915 to @w{remote/origin/master} by someone else and Fetched, your
916 lily-local branch is divergent.  You can detect a divergent
917 branch by clicking on
918
919 @example
920 Repository -> Visualise all branch history
921 @end example
922
923 This opens up a very useful new window called @q{gitk}.
924 Use this to browse all the commits made by others.
925
926 If the diagram at top left of the resulting window
927 does not show your branch's tag on the same node as
928 the @w{remote/origins/master} tag your branch has diverged from
929 @w{origin/master}.  This is quite normal if files you have modified
930 yourself have not yet been Pushed to @w{remote/origin/master} and
931 Fetched, or if files modified and committed by others have been
932 Fetched since you last Merged @w{origin/master} into your lily-local
933 branch.
934
935 If a file being merged from @w{origin/master} differs from
936 one you have modified in a way that cannot be resolved
937 automatically by git, Merge will report a Conflict
938 which you must resolve by editing the file to create the
939 version you wish to keep.
940
941 This could happen if the person updating @w{remote/origin/master}
942 for you has added some changes of his own before
943 committing your changes to @w{remote/origin/master}, or if someone
944 else has changed the same file since you last
945 fetched the file from @w{remote/origin/master}.
946
947 Open the file in your editor and look for sections which
948 are delimited with ...
949
950 [to be completed when I next have a merge conflict to be
951 sure I give the right instructions  -td]
952
953
954 @subsection Other actions
955
956 The instructions above describe the simplest way of using
957 git on Windows.  Other git facilities which may usefully
958 supplement these include
959
960 @itemize
961
962 @item Using multiple local branches (Create, Rename, Delete)
963 @item Resetting branches
964 @item Cherry-picking commits
965 @item Pushing commits to @w{remote/origin/master}
966 @item Using gitk to review history
967
968 @end itemize
969
970 Once familiarity with using git on Windows has been gained the
971 standard git manuals can be used to learn about these.
972
973
974 @node Development inside VirtualBox (compiling on Windows)
975 @section Development inside VirtualBox (compiling on Windows)
976
977
978
979