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