Clarify that \set without explicit context uses the current context, not always Voice...
[lilypond/mpolesky.git] / Documentation / contributor / git-starting.itexi
blobfb45b5966575311c24aaa2371b95684675a7351c
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @node Starting with git
3 @chapter Starting with git
5 The goal of this chapter is to provide all the git commands that
6 contributors should know for basic lilypond development.  However,
7 to complete or present in another form the introduction to Git
8 usage in this chapter, it may be a good idea to look at the other
9 Git documentation listed in @ref{Other git documentation}.
11 @menu
12 * Getting the source code::     
13 * Updating the source code::    
14 * Sharing your changes::        
15 * Advanced git stuff::          
16 * Git on Windows::
17 * Other git documentation::
18 * Roadmap of directories::
19 @end menu
22 @node Getting the source code
23 @section Getting the source code
25 @menu
26 * Git introduction::            
27 * Git user configuration::      
28 * Main source code::            
29 * Documentation translations source code::  
30 * Other branches::              
31 * Other locations for git::     
32 @end menu
34 @node Git introduction
35 @subsection Git introduction
37 The source code is kept in a Git respository.  This allows us to
38 track changes to files, and for multiple people to work on the
39 same set of files efficiently.
41 After downloading the source code, it is important to update the
42 repository by @ref{Updating the source code}.
44 @warning{These instructions assume that you are using the
45 command-line version of Git 1.5 or higher.  Windows users should
46 skip to @ref{Git on Windows}.}
49 @node Git user configuration
50 @subsection Git user configuration
52 Some useful cofiguration can be performed automatically; cut and
53 paste the following section:
55 @example
56 git config --global color.ui auto
57 @end example
59 To configure git to automatically use your name and email address
60 for commits and patches, edit the below lines by changing all the
61 @code{MY...} entries:
63 @example
64 git config --global user.name "MYNAME"
65 git config --global user.email MYEMAIL@@EXAMPLE.NET
66 @end example
69 @node Main source code
70 @subsection Main source code
72 To get the main source code and documentation,
74 @c WARNING: when updating the commands below, please
75 @c update the other flavors in the two next nodes
76 @c and in Introduction to Git concepts
77 @smallexample
78 mkdir lilypond; cd lilypond
79 git init
80 git remote add -f -t master -m master origin git://git.sv.gnu.org/lilypond.git/
81 git checkout -b master origin/master
82 @end smallexample
85 @node Documentation translations source code
86 @subsection Documentation translations source code
88 To translate the documentation,
90 @smallexample
91 mkdir lilypond-translation; cd lilypond-translation
92 git init
93 git remote add -f -t lilypond/translation -m lilypond/translation origin git://git.sv.gnu.org/lilypond.git/
94 git checkout -b lilypond/translation origin/lilypond/translation
95 @end smallexample
98 @node Other branches
99 @subsection Other branches
101 Most contributors will never need to touch the other branches.  If
102 you wish to do so, you will need more familiarity with git; please
103 see @ref{Other git documentation}.
105 @itemize
107 @item @code{dev/XYZ}:
108 These branches are for individual developers.  They store code
109 which is not yet stable enough to be added to the @code{master}
110 branch.
112 @item @code{stable/XYZ}:
113 The branches are kept for archival reasons.
115 @end itemize
117 Another item of interest might be the Grand Unified Builder, our
118 cross-platform building tool.  Since it is used by projects as
119 well, it is not stored in our gub repository.  For more info, see
120 @uref{http://lilypond.org/gub}.  The git location is:
122 @example
123 http://github.com/janneke/gub
124 @end example
127 @node Other locations for git
128 @subsection Other locations for git
130 If you have difficulty connecting to most of the repositories
131 listed in earlier sections, try:
133 @example
134 http://git.sv.gnu.org/r/lilypond.git
135 git://git.sv.gnu.org/lilypond.git
136 ssh://git.sv.gnu.org/srv/git/lilypond.git
137 @end example
139 Using HTTP protocol is slowest, so it is not recommended unless both
140 SSH and Git protocols fail, which happens e.g. if you connect to
141 internet through a router that filters out Git and/or SSH connections.
145 @node Updating the source code
146 @section Updating the source code
148 @menu
149 * Importance of updating::      
150 * Update command::              
151 * Resolving conflicts::         
152 @end menu
155 @node Importance of updating
156 @subsection Importance of updating
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 big problems can arise if you do not pull before attempting to
163 commit.  If this occurs, see @ref{Resolving conflicts}.
166 @node Update command
167 @subsection Updating command
169 Whenever you are asked to pull, it means you should update your
170 local copy of the repository with the changes made by others on
171 the remote @code{git.sv.gnu.org} repository:
173 @example
174 git pull -r
175 @end example
177 @noindent
178 The @code{-r} option is short for @code{--rebase}.  If you don't
179 edit translated documentation and don't want to type @code{-r}
180 every time, add @code{rebase = true} to the master branch in your
181 @file{.git/config}, like so:
183 @example
184 [branch "master"]
185         remote = origin
186         merge = refs/heads/master
187         rebase = true
188 @end example
190 @warning{translators and documentation editors, if you have
191 changed committishes in the head of translated files using commits
192 you have not yet pushed to @code{git.sv.gnu.org}, please do not
193 rebase.  If you want to avoid wondering whether you should rebase
194 each time you pull, please always use committishes from master
195 and/or lilypond/translation branch on @code{git.sv.gnu.org}, which
196 in particular implies that you must push your changes to
197 documentation except committishes updates (possibly after having
198 rebased), then update the committishes and push them.}
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.
206 @node Resolving conflicts
207 @subsection Resolving conflicts
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.
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.
219 If all else fails, you can follow the instructions in
220 @ref{Reverting all local changes}.  Be aware that this eliminates
221 any changes you have made!
224 @node Sharing your changes
225 @section Sharing your changes
227 @menu
228 * Producing a patch::           
229 * Committing directly::         
230 @end menu
233 @node Producing a patch
234 @subsection Producing a patch
236 Once you have finished editing your files, checked that your changes
237 meet the @ref{Code style}, and/or @ref{Documentation policy}, properly
238 set up your name and email in @ref{Git user configuration}, and
239 checked that the entire thing compiles, you may:
241 @example
242 git commit -a
243 git format-patch origin
244 @end example
246 The commit should include a brief message describing the change.
247 This consists of a one-line summary describing the change, and
248 if necessary a blank line followed by several lines giving the
249 details:
251 @example
252 Did household chores.
254 I hung up the wet laundry and then washed the car.  I also
255 vacuumed the floors, rinsed the dirty dishes, fed the cat, and
256 recalibrated the temporal flux machine.
257 @end example
259 If the change is to the documentation only then the one-line
260 summary should be prefixed with @qq{Docs: }.
262 If you added a file to the source code, you must add it to git
263 with:
265 @example
266 git add @var{FILENAME}
267 @end example
269 @noindent
270 (and possibly modify the @file{GNUmakefile})
272 These commands will produce one or more files named @file{0001-xyz},
273 @file{0002-abc}, etc. in the top directory of the git tree.  Send an
274 email to @email{lilypond-devel@@gnu.org} with these files attached, and
275 a developer will review and apply the patches to the main repository.
276 If your patch is some translation work, you may send it to
277 @email{translations@@lilynet.net} instead.
279 To check if you have correctly added any new files, use:
281 @example
282 git status
283 @end example
285 @noindent
286 If this command lists any @emph{Changed but not updated} files,
287 you should do a @command{git commit}.  If it lists any
288 @emph{Untracked files}, then you should do a @command{git add}.
290 @seealso
292 If your patch includes a significant amount of code, you may want to see
293 @ref{Adding or modifying features}, especially @emph{Post patch for
294 comments}.
297 @node Committing directly
298 @subsection Committing directly
300 Most contributors do not have permission to commit directly.  If you do,
301 make sure you have set up your name and email in @ref{Git user
302 configuration}, then edit @file{.git/config}: change the line
304 @example
305 url = git://git.sv.gnu.org/lilypond.git/
306 @end example
308 @noindent
309 into
311 @example
312 url = ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond.git
313 @end example
315 @noindent
316 where @var{user} is your login name on Savannah.
318 If you have not already done so, you should generate and upload a
319 SSH key: open @uref{https://savannah.gnu.org/my/} in your browser,
320 go to @q{Account Configuration}, then to something like
321 @q{Edit SSH Keys}, and follow the instructions on that page.
323 You may then:
325 @example
326 git push origin
327 @end example
329 Note that recent versions of Git (Git 1.6.3 or later) will issue a
330 big warning if the above command is used.  The simplest solution
331 is to add a new section to @file{.git/config} that looks like
332 this:
334 @example
335 [push]
336         default = matching
337 @end example
339 @noindent
340 Then @code{git push origin} will work as before.  For more
341 details, consult the @code{git push} man page.
344 @node Advanced git stuff
345 @section Advanced git stuff
347 @warning{This section is not necessary for normal contributors;
348 these commands are presented for information for people interested
349 in learning more about git.}
352 It is possible to work with several branches on the same local Git
353 repository; this is especially useful for translators who may have to
354 deal with both @code{lilypond/translation} and a stable branch,
355 e.g. @code{stable/2.12}.
357 Some Git commands are introduced first, then a workflow with several
358 Git branches of LilyPond source code is presented.
360 @menu
361 * Introduction to Git concepts::  
362 * Git commands for managing several branches::  
363 * Working on LilyPond sources with several branches::  
364 * Git log::
365 * Using local git branches::
366 * Applying git patches::        
367 * Reverting all local changes::  
368 @end menu
371 @node Introduction to Git concepts
372 @subsection Introduction to Git concepts
374 A bit of Git vocabulary will be explained below.  The following is
375 just introduction material; for better understanding of Git concepts,
376 you are invited to read further documentation, especially Git
377 Community Book at @uref{http://book.git-scm.com/}.
379 The @code{git pull origin} command above is just a shortcut for this
380 command:
382 @example
383 git pull git://git.sv.gnu.org/lilypond.git/ @var{branch}:origin/@var{branch}
384 @end example
386 @noindent
387 where @code{@var{branch}} is typically @code{master}, @code{web} or
388 @code{lilypond/translation}; if you do not know or remember, see
389 @ref{Getting the source code} to remember which commands you issued or
390 which source code you wanted to get.
392 A @emph{commit} is a set of changes made to the sources; it also
393 includes the committish of the parent commit, the name and e-mail of
394 the @emph{author} (the person who wrote the changes), the name and
395 e-mail of the @emph{committer} (the person who brings these changes
396 into the Git repository), and a commit message.
398 A @emph{committish} is the SHA1 checksum of a commit, a number made of
399 40 hexadecimal digits, which acts as the internal unique identifier
400 for this commit.  To refer to a particular revision, don't use vague
401 references like the (approximative) date, simply copy and paste the
402 committish.
404 A @emph{branch} is nothing more than a pointer to a particular commit,
405 which is called the @emph{head} of the branch; when referring to a
406 branch, one often acutally thinks about its head and the ancestor
407 commits of the head.
409 Now we will explain the two last commands you used to get the source
410 code from Git -- see @ref{Getting the source code}.
412 @example
413 git remote add -f -t @var{branch} -m @var{branch} origin git://git.sv.gnu.org/lilypond.git/
414 git checkout -b @var{branch} origin/@var{branch}
415 @end example
417 The @command{git remote} has created a branch called
418 @code{origin/@var{branch}} in your local Git repository.  As this
419 branch is a copy of the remote branch web from git.sv.gnu.org LilyPond
420 repository, it is called a @emph{remote branch}, and is meant to track
421 the changes on the branch from git.sv.gnu.org: it will be updated
422 every time you run @command{git pull origin} or @command{git fetch
423 origin}.
425 The @command{git checkout} command has created a branch named
426 @code{@var{branch}}.  At the beginning, this branch is identical to
427 @code{origin/@var{branch}}, but it will differ as soon as you make
428 changes, e.g. adding newly translated pages or editing some
429 documentation or code source file.  Whenever you pull, you merge the
430 changes from @code{origin/@var{branch}} and @code{@var{branch}} since
431 the last pulling.  If you do not have push (i.e. @qq{write}) access on
432 git.sv.gnu.org, your @code{@var{branch}} will always differ from
433 @code{origin/@var{branch}}.  In this case, remember that other people
434 working like you with the remote branch @code{@var{branch}} of
435 git://git.sv.gnu.org/lilypond.git/ (called @code{origin/@var{branch}}
436 on your local repository) know nothing about your own
437 @code{@var{branch}}: this means that whenever you use a committish or
438 make a patch, others expect you to take the latest commit of
439 @code{origin/@var{branch}} as a reference.
441 Finally, please remember to read the man page of every Git command you
442 will find in this manual in case you want to discover alternate
443 methods or just understand how it works.
446 @node Git commands for managing several branches
447 @subsection Git commands for managing several branches
449 @subsubheading Listing branches and remotes
451 You can get the exact path or URL of all remotes with
452 running
454 @example
455 git remote -v
456 @end example
458 To list Git branches on your local repositories, run
460 @example
461 git branch     # list local branches only
462 git branch -r  # list remote branches
463 git branch -a  # list all branches
464 @end example
467 @subsubheading Checking out branches
469 To know the currently checked out branch, i.e. the branch whose source
470 files are present in your working tree, read the first line of the
471 output of
473 @example
474 git status
475 @end example
477 @noindent
478 The currently checked out branch is also marked with an asterisk in
479 the output of @command{git branch}.
481 You can check out another branch @code{@var{other_branch}}, i.e. check
482 out @code{@var{other_branch}} to the working tree, by running
484 @example
485 git checkout @var{other_branch}
486 @end example
488 Note that it is possible to check out another branch while having
489 uncommitted changes, but it is not recommended unless you know what
490 you are doing; it is recommended to run @command{git status} to check
491 this kind of issue before checking out another branch.
494 @subsubheading Merging branches
496 To merge branch @code{@var{foo}} into branch @code{@var{bar}}, i.e. to
497 @qq{add} all changes made in branch @code{@var{foo}} to branch
498 @code{@var{bar}}, run
500 @example
501 git checkout @var{bar}
502 git merge @var{foo}
503 @end example
505 If any conflict happens, see @ref{Resolving conflicts}.
507 There are common usage cases for merging: as a translator, you will
508 often want to merge @code{master} into @code{lilypond/translation}; on
509 the other hand, the Translations meister wants to merge
510 @code{lilypond/translation} into @code{master} whenever he has checked
511 that @code{lilypond/translation} builds successfully.
514 @node Working on LilyPond sources with several branches
515 @subsection Working on LilyPond sources with several branches
517 @subsubheading Fetching new branches from git.sv.gnu.org
519 To fetch and check out a new branch named @code{@var{branch}} on
520 git.sv.gnu.org, run from top of the Git repository
522 @example
523 git config --add remote.origin.fetch +refs/heads/@var{branch}:refs/remotes/origin/@var{branch}
524 git checkout --track -b @var{branch} origin/@var{branch}
525 @end example
527 After this, you can pull @code{@var{branch}} from git.sv.gnu.org with
529 @example
530 git pull origin
531 @end example
533 Note that this command generally fetches all branches you added with
534 @command{git remote add} (when you initialized the repository) or
535 @command{git config --add}, i.e. it updates all remote branches from
536 remote @code{origin}, then it merges the remote branch tracked by
537 current branch into current branch.  For example, if your current
538 branch is @code{master} --- which is the case if you got the sources
539 with the commands described in @ref{Main source code} and did not
540 issue any @command{git checkout} command --- @code{origin/master} will
541 be merged into @code{master}.
544 @subsubheading Local clones, or having several working trees
546 If you play with several Git branches, e.g. @code{master},
547 @code{lilypond/translation}, @code{stable/2.12}), you may want to have
548 one source and build tree for each branch; this is possible with
549 subdirectories of your local Git repository, used as local cloned
550 subrepositories.  To create a local clone for the branch named
551 @code{@var{branch}}, run
553 @example
554 git checkout @var{branch}
555 git clone -l -s -n . @var{subdir}
556 cd @var{subdir}
557 git reset --hard
558 @end example
560 Note that @code{@var{subdir}} must be a directory name which does not
561 already exist.  In @code{@var{subdir}}, you can use all Git commands
562 to browse revisions history, commit and uncommit changes; to update
563 the cloned subrepository with changes made on the main repository, cd
564 into @code{@var{subdir}} and run @command{git pull}; to send changes
565 made on the subrepository back to the main repository, run
566 @command{git push} from @code{@var{subdir}}.  Note that only one
567 branch (the currently checked out branch) is created in the
568 subrepository by default; it is possible to have several branches in a
569 subrepository and do usual operations (checkout, merge, create,
570 delete...) on these branches, but this possibility is not detailed
571 here.
573 When you push @code{@var{branch}} from @code{@var{subdir}} to the main
574 repository, and @code{@var{branch}} is checked out in the main
575 repository, you must save uncommitted changes (see @command{git
576 stash}) and do @command{git reset --hard} in the main repository in
577 order to apply pushed changes in the working tree of the main
578 repository.
581 @node Git log
582 @subsection Git log
584 The commands above don't only bring you the latest version of the
585 sources, but also the full history of revisions (revisons, also
586 called commits, are changes made to the sources), stored in the
587 .git directory.  You can browse this history with
589 @example
590 git log     # only shows the logs (author, committish and commit message)
591 git log -p  # also shows diffs
592 gitk        # shows history graphically
593 @end example
595 @warning{The @code{gitk} command may require a separate @code{gitk} package,
596 available in the appropriate distribution's repositories.}
598 @node Using local git branches
599 @subsection Using local git branches
601 Branches can also be created for local document editing or code
602 development.  They permit the editor to work on several
603 streams at once simply by switching between branches.  The use of
604 separate branches by code developers, who may be working on changes
605 for an extended period, is essential.
607 A branch based on the current state of master is created by
608 checking out master and entering the command
610 @example
611 git branch @var{local-branch-name}
612 @end example
614 and deleted with the command
616 @example
617 git branch -d @var{local-branch-name}
618 @end example
620 The list of all branches can be obtained with
622 @example
623 git branch -a
624 @end example
626 and their relation to other branches may be seen with gitk.
628 When all the changes you wish to make to a local branch are
629 complete and committed you may merge them into master; see
630 @ref{Git commands for managing several branches}.  Alternatively
631 individual commits may be cherry-picked from one branch to
632 another.  Gitk provides the easiest way of doing this.
634 If your local copy of master has been updated since one of your
635 local branches was created you may wish to insert the new commits
636 in master @qq{underneath} your commits in your local branch.  This
637 is achieved with the rebase command:
639 @example
640 git rebase --whitespace=fix master @var{local-branch-name}
641 @end example
643 You should always update master and rebase your local branch in
644 this way before generating a patch.  It is also a convenient way
645 of removing whitespace errors from your local edits before merging
646 and pushing to origin/master.
648 @node Applying git patches
649 @subsection Applying git patches
651 Well-formed git patches created with @code{git format-patch}
652 should be committed with the following command:
654 @example
655 git am @var{patch}
656 @end example
658 Patches created without @code{git format-patch} can be applied in
659 two steps.  The first step is to apply the patch to the working
660 tree:
662 @example
663 git apply @var{patch}
664 @end example
666 @noindent
667 The second step is to commit the changes and give credit to the
668 author of the patch.  This can be done with the following command:
670 @example
671 git commit -a --author="First Last <user@@example.net>"
672 @end example
675 @node Reverting all local changes
676 @subsection Reverting all local changes
678 Sometimes git will become hopelessly confused, and you just want
679 to get back to a known, stable state.  This command destroys any
680 local changes you have made, but at least you get back to the
681 current online version:
683 @example
684 git reset --hard origin/master
685 @end example
688 @node Git on Windows
689 @section Git on Windows
691 @c Some of this may duplicate stuff in other sections
692 @c But it is probably best for windows users to have it all together
693 @c If necessary, clear this up later  -td
695 @subsection Background to nomenclature
697 Git is a system for tracking the changes made to source files by
698 a distributed set of editors.  It is designed to work without a
699 master repository, but we have chosen to have a master respository
700 for LilyPond files.  Editors hold a local copy of the master
701 repository together with any changes they have made locally.  Local
702 changes are held in a local @q{branch}, of which there may be
703 several, but these instructions assume you are using just one.  The
704 files visible in the local repository always correspond to those
705 on the currently @q{checked out} local branch.
707 Files are edited on a local branch, and in that state the
708 changes are said to be @q{unstaged}.  When editing is complete, the
709 changes are moved to being @q{staged for commit}, and finally the
710 changes are @q{committed} to the local branch.  Once committed, the
711 changes (called a @q{commit}) are given a unique 40-digit hexadecimal
712 reference number called the @q{Committish} or @q{SHA1 ID} which
713 identifies the commit to Git.  Such committed changes can be sent to
714 the master repository by @q{pushing} them (if you have write
715 permission) or by sending them by email to someone who has, either
716 as a complete file or as a @q{diff} or @q{patch} (which send just
717 the differences from the master repository).
719 @subsection Installing git
721 Obtain Git from
722 @uref{http://code.google.com/p/msysgit/downloads/list}
723 (note, not msysGit, which is for Git developers and not PortableGit,
724 which is not a full git installation) and
725 install it.
727 Note that most users will not need to install SSH.  That is not
728 required until you have been granted direct push permissions to
729 the master git repository.
731 Start Git by clicking on the desktop icon.
732 This will bring up a command line bash shell.  This may be
733 unfamiliar to Windows users.  If so, follow these
734 instructions carefully.  Commands are entered at a $ prompt
735 and are terminated by keying a newline.
737 @subsection Initialising Git
739 Decide where you wish to place your local Git repository,
740 creating the folders in Windows as necessary.  Here we
741 call the folder to contain the repository @code{[path]/Git}, but 
742 if you intend using Git for other projects a directory name like
743 @code{lilypond-git} might be better.  You will need to have space
744 for around 100Mbytes.
746 Start the Git bash shell by clicking on the desk-top icon installed
747 with Git and type
749 @example
750 cd [path]/Git
751 @end example
753 to position the shell at your new Git repository.
755 Note: if [path] contains folders with names containing
756 spaces use
758 @example
759 cd "[path]/Git"
760 @end example
762 Then type
764 @example
765 git init
766 @end example
768 to initialize your Git repository.
770 Then type (all on one line; the shell will wrap automatically)
772 @example
773 git remote add -f -t master origin git://git.sv.gnu.org/lilypond.git
774 @end example
776 to download the lilypond master files.
778 @warning{Be patient!  Even on a broadband connection this can take
779 10 minutes or more.  Wait for lots of [new tag] messages
780 and the $ prompt.}
782 We now need to generate a local copy of the downloaded files
783 in a new local branch.  Your local branch needs to have a
784 name.  It is usual to call it @q{master} and we shall do that
785 here.
787 To do this, type
789 @example
790 git checkout -b master origin/master
791 @end example
793 This creates a second branch called @q{master}.  You will see
794 two warnings (ignore these), and a message advising you that
795 your local branch @q{master} has been set up to track the remote
796 branch.  You now have two branches, a local branch called
797 @q{master}, and a tracking branch called @q{origin/master},
798 which is a shortened form of @q{remotes/origin/master}.
800 Return to Windows Explorer and look in your Git repository.  You
801 should see lots of folders.  For example, the LilyPond documentation
802 can be found in [path]/Git/Documentation/.
804 The Git bash shell is terminated by typing @code{exit} or by
805 clicking on the usual Windows close-window widget.
807 @subsection Git GUI
809 Almost all subsequent work will use the Git Graphical User
810 Interface, which avoids having to type command line
811 commands. To start Git GUI first start the Git bash shell by
812 clicking on the desktop icon, and type
814 @example
815 cd [path]/Git
816 git gui
817 @end example
819 The Git GUI will open in a new window.  It contains four panels
820 and 7 pull-down menus.  At this stage do not use any of the
821 commands under Branch, Commit, Merge or Remote.  These will
822 be explained later.
824 The top panel on the left contains the names of files which
825 you are in the process of editing (Unstaged Changes), and the
826 lower panel on the left contains the names of
827 files you have finished editing and have staged ready for
828 committing (Staged Changes).  At present, these panels will
829 be empty as you have not yet made any changes to any file.
830 After a file has been edited and saved the top panel on the right
831 will display the differences between the edited file selected
832 in one of the panels on the left and the last version committed
833 on the current branch.
835 The panel at bottom right is used to enter a descriptive
836 message about the change before committing it.
838 The Git GUI is terminated by entering CNTL-Q while it is the
839 active window or by clicking on the usual Windows close-window
840 widget.
842 @subsection Personalising your local git repository
844 Open the Git GUI, click on
846 @example
847 Edit -> Options
848 @end example
850 and enter your name and email address in the
851 left-hand (Git Repository) panel.  Leave everything
852 else unchanged and save it.
854 Note that Windows users must leave the default setting for line
855 endings unchanged.  All files in a git repository must have lines
856 terminated by just a LF, as this is required for Merge to work, but
857 Windows files are terminated by CRLF by default.  The git default
858 setting causes the line endings of files in a Windows git repository
859 to be flipped automatically between LF and CRLF as required.  This
860 enables files to be edited by any Windows editor without causing
861 problems in the git repository.
863 @subsection Checking out a branch
865 At this stage you have two branches in your local repository,
866 both identical.  To see them click on
868 @example
869 Branch -> Checkout
870 @end example
872 You should have one local branch called @q{master} and one
873 tracking branch called @q{origin/master}.  The latter is your
874 local copy of the @q{remotes/origin/master} branch in the master
875 LilyPond repository.  The local @q{master} branch is where you
876 will make your local changes.
878 When a particular branch is selected, i.e., checked out, the
879 files visible in your repository are changed to reflect the
880 state of the files on that branch.
882 @subsection Updating files from @q{remote/origin/master}
884 Before starting the editing of a file, ensure your local repository
885 contains the latest version of the files in the remote repository
886 by first clicking
888 @example
889 Remote -> Fetch from -> origin
890 @end example
892 @noindent
893 in the Git GUI.
895 This will place the latest version of every file, including all the
896 changes made by others, into the @q{origin/master} branch of the
897 tracking branches in your git repository.  You can see these files
898 by checking out this branch, but you must @emph{never} edit any
899 files while this branch is checked out.  Check out your local
900 @q{master} branch again.
902 You then need to merge these fetched files into your local @q{master}
903 branch by clicking on
905 @example
906 Merge -> Local Merge
907 @end example
909 @noindent
910 and if necessary select the local @q{master} branch.
912 Note that a merge cannot be completed if you have made any local
913 changes which have not yet been committed.
915 This merge will update all the files in the @q{master} branch to
916 reflect the current state of the @q{origin/master} branch.  If any
917 of the changes conflict with changes you have made yourself recently
918 you will be notified of the conflict (see below).
920 @subsection Editing files
922 First ensure your @q{master} branch is checked out, then
923 simply edit the files in your local Git repository with your
924 favourite editor and save them back there.  If any file contains
925 non-ASCII characters ensure you save it in UTF-8 format.  Git will
926 detect any changes whenever you restart Git GUI and the file names
927 will then be listed in the Unstaged Changes panel.
928 Or you can click the Rescan button to refresh the panel
929 contents at any time.  You may break off and resume editing any
930 time.
932 The changes you have made may be displayed in diff form in the top
933 right-hand panel of Git GUI by clicking on the file name shown in
934 one of the left panels.
936 When your editing is complete, move the files from being
937 Unstaged to Staged by clicking the document symbol to
938 the left of each name.  If you change your mind it can
939 be moved back by clicking on the ticked box to the
940 left of the name.
942 Finally the changes you have made may be committed to
943 your @q{master} branch by entering a brief message in
944 the Commit Message box and clicking the Commit button.
946 If you wish to amend your changes after a commit has been
947 made, the original version and the changes you made in that
948 commit may be recovered by selecting
950 @example
951 Commit -> Amend Last Commit
952 @end example
954 @noindent
955 or by checking the Amend Last Commit radio button at bottom right.
956 This will return the changes to the Staged state, so further
957 editing made be carried out within that commit.  This must only be
958 done @emph{before} the changes have been Pushed or sent to your
959 mentor for Pushing - after that it is too late and corrections
960 have to be made as a separate commit.
963 @subsection Sending changes to @q{remotes/origin/master}
965 If you do not have write access to @q{remotes/origin/master} you
966 will need to send your changes by email to someone who does.
968 First you need to create a diff or patch file containing
969 your changes.  To create this, the file must first be
970 committed.  Then terminate the Git GUI.  In the
971 git bash shell first cd to your Git repository with
973 @example
974 cd [path]/Git
975 @end example
977 if necessary, then produce the patch with
979 @example
980 git format-patch origin
981 @end example
983 This will create a patch file for all the locally committed files
984 which differ from @q{origin/master}.  The patch file can be found
985 in [path]/Git and will have a name formed from the commit
986 message.
988 @subsection Resolving merge conflicts
990 As soon as you have committed a changed file your local @q{master}
991 branch has diverged from @q{origin/master}, and will
992 remain diverged until your changes have been committed
993 in @q{remotes/origin/master} and Fetched back into your
994 @q{origin/master} branch.  Similarly, if a new commit has been made
995 to @q{remotes/origin/master} by someone else and Fetched, your
996 local @q{master} branch is divergent.  You can detect a divergent
997 branch by clicking on
999 @example
1000 Repository -> Visualise all branch history
1001 @end example
1003 This opens up a very useful new window called @q{gitk}.
1004 Use this to browse all the commits made by yourself and others.
1006 If the diagram at top left of the resulting window
1007 does not show your @q{master} tag on the same node as
1008 the @q{remotes/origin/master} tag your branch has diverged from
1009 @q{origin/master}.  This is quite normal if files you have modified
1010 yourself have not yet been Pushed to @q{remotes/origin/master} and
1011 Fetched, or if files modified and committed by others have been
1012 Fetched since you last Merged @q{origin/master} into your local
1013 @q{master} branch.
1015 If a file being merged from @q{origin/master} differs from
1016 one you have modified in a way that cannot be resolved
1017 automatically by git, Merge will report a Conflict
1018 which you must resolve by editing the file to create the
1019 version you wish to keep.
1021 This could happen if the person updating @q{remotes/origin/master}
1022 for you has added some changes of his own before
1023 committing your changes to @q{remotes/origin/master}, or if someone
1024 else has changed the same file since you last
1025 fetched the file from @q{remotes/origin/master}.
1027 Open the file in your editor and look for sections which
1028 are delimited with ...
1030 [to be completed when I next have a merge conflict to be
1031 sure I give the right instructions  -td]
1034 @subsection Other actions
1036 The instructions above describe the simplest way of using
1037 git on Windows.  Other git facilities which may usefully
1038 supplement these include
1040 @itemize
1042 @item Using multiple local branches (Create, Rename, Delete)
1043 @item Resetting branches
1044 @item Cherry-picking commits
1045 @item Pushing commits to @w{remote/origin/master}
1046 @item Using gitk to review history
1048 @end itemize
1050 Once familiarity with using git on Windows has been gained the
1051 standard git manuals can be used to learn about these.
1054 @node Other git documentation
1055 @section Other git documentation
1057 @itemize
1059 @item
1060 Official git man pages: @uref{http://www.kernel.org/pub/software/scm/git/docs/}
1062 @item
1063 More in-depth tutorials: @uref{http://git-scm.com/documentation}
1065 @item
1066 Book about git: @uref{http://progit.org/,Pro Git}
1068 @end itemize
1071 @node Roadmap of directories
1072 @section Roadmap of directories
1074 @c TODO: integrate the roadmap better
1075 @verbatiminclude ROADMAP