1 @c -*- coding: utf-8; mode: texinfo; -*-
4 @node Working with source code
5 @chapter Working with source code
7 @warning{New contributors should read @ref{Quick start}, and in
8 particular @ref{lily-git}, instead of this chapter.}
10 Advanced contributors will find this material quite useful,
11 particularly if they are working on major new features.
14 * Manually installing lily-git.tcl::
16 * Basic Git procedures::
17 * Advanced Git procedures::
19 * Repository directory structure::
20 * Other Git documentation::
24 @node Manually installing lily-git.tcl
25 @section Manually installing lily-git.tcl
27 We have created an easy-to-use GUI to simplify git for new
28 contributors. If you are comfortable with the command-line, then
29 skip ahead to @ref{Starting with Git}.
31 @warning{These instructions are only for people who are @emph{not}
34 @c there's some duplication in this section with stuff covered in
35 @c Quick Start, but moving it into a macro inside included/ would
36 @c be getting a bit icky. -gp
40 If you haven't already, download and install Git.
44 @item Windows users: download the @code{.exe} file labeled
45 @qq{Full installer for official Git} from:
48 @uref{http://code.google.com/p/msysgit/downloads/list}
51 @item Other operating systems: either install @command{git} with
52 your package manager, or download it from the @qq{Binaries}
56 @uref{http://git-scm.com/download}
63 Download the @command{lily-git.tcl} script from:
65 @c don't change the cgit link below to gitweb; gitweb uses
66 @c long filenames like "scripts_auxiliar_lily-git.tcl"
69 @uref{http://git.sv.gnu.org/cgit/lilypond.git/plain/scripts/auxiliar/lily-git.tcl}
73 To run the program from the command line, navigate to the
74 directory containing @command{lily-git.tcl} and enter:
81 Click on the @qq{Get source} button.
83 This will create a directory called @file{lilypond-git/} within
84 your home directory, and will download the source code into that
85 directory (around 150@tie{}Mb). When the process is finished, the
86 @qq{Command output} window will display @qq{Done}, and the button
87 label will change to say @qq{Update source}.
90 Navigate to the @file{lilypond-git/} directory to view the source
95 @warning{Throughout the rest of this manual, most command-line
96 input should be entered from @file{$LILYPOND_GIT}. This is
97 referred to as the @emph{top source directory}.}
99 Further instructions are in @ref{How to use lily-git}.
102 @node Starting with Git
103 @section Starting with Git
105 Using the Git program directly (as opposed to using the
106 @command{lily-git.tcl} GUI) allows you to have much greater control
107 over the contributing process. You should consider using Git if
108 you want to work on complex projects, or if you want to work on
109 multiple projects concurrently.
114 * Git for the impatient::
115 * Other repositories::
116 * Downloading remote branches::
121 @subsection Setting up
123 @warning{These instructions assume that you are using the
124 command-line version of Git 1.5 or higher. Windows users should
125 skip to @ref{Git on Windows}.}
129 * Initializing a repository::
135 @unnumberedsubsubsec Installing Git
137 If you are using a Unix-based machine, the easiest way to download
138 and install Git is through a package manager such as @command{rpm}
139 or @command{apt-get} -- the installation is generally automatic.
140 The only required package is (usually) called @command{git-core},
141 although some of the auxiliary @command{git@var{*}} packages are
142 also useful (such as @command{gitk}).
144 Alternatively, you can visit the Git website
145 (@uref{http://git-scm.com/}) for downloadable binaries and
149 @node Initializing a repository
150 @unnumberedsubsubsec Initializing a repository
152 Once Git is installed, get a copy of the source code:
155 git clone git://git.sv.gnu.org/lilypond.git ~/lilypond-git
158 The above command will put the it in @file{~/lilypond-git}, where
159 @code{~} represents your home directory.
161 @subsubheading Technical details
163 This creates (within the @file{$LILYPOND_GIT} directory) a
164 subdirectory called @file{.git/}, which Git uses to keep track of
165 changes to the repository, among other things. Normally you don't
166 need to access it, but it's good to know it's there.
169 @node Configuring Git
170 @unnumberedsubsubsec Configuring Git
172 @warning{Throughout the rest of this manual, all command-line
173 input should be entered from the top directory of the Git
174 repository being discussed (eg. @file{$LILYPOND_GIT}). This is
175 referred to as the @emph{top source directory}.}
177 Before working with the copy of the main LilyPond repository, you
178 should configure some basic settings with the
179 @command{git@tie{}config} command. Git allows you to set both
180 global and repository-specific options.
182 To configure settings that affect all repositories, use the
183 @option{--global} command line option. For example, the first
184 two options that you should always set are your @var{name} and
185 @var{email}, since Git needs these to keep track of commit
189 git config --global user.name "@var{John Smith}"
190 git config --global user.email @var{john@@example.com}
193 To configure Git to use colored output where possible, use:
196 git config --global color.ui auto
199 The text editor that opens when using @command{git@tie{}commit}
200 can also be changed. If none of your editor-related environment
201 variables are set ($GIT_EDITOR, $VISUAL, or $EDITOR), the default
202 editor is usually @command{vi} or @command{vim}. If you're not
203 familiar with either of these, you should probably change the
204 default to an editor that you know how to use. For example, to
205 change the default editor to @command{nano}, enter:
208 git config --global core.editor @var{nano}
211 Finally, and in some ways most importantly, let's make sure that
212 we know what branch we're on. If you're not using LilyDev, add
213 this to your @file{~/.bashrc}:
216 export PS1="\u@\h \w\$(__git_ps1)$ "
219 If you are not using LilyDev, you may need to install the
220 additional @code{git-completion} package, but it is definitely
224 @subsubheading Technical details
226 Git stores the information entered with
227 @command{git@tie{}config@tie{}--global} in the file
228 @file{.gitconfig}, located in your home directory. This file can
229 also be modified directly, without using
230 @command{git@tie{}config}. The @file{.gitconfig} file generated
231 by the above commands would look like this:
236 email = john@@example.com
243 Using the @command{git@tie{}config} command @emph{without} the
244 @option{--global} option configures repository-specific settings,
245 which are stored in the file @file{.git/config}. This file is
246 created when a repository is initialized (using
247 @command{git@tie{}init}), and by default contains these lines:
251 repositoryformatversion = 0
254 logallrefupdates = true
257 However, since different repository-specific options are
258 recommended for different development tasks, it is best to avoid
259 setting any now. Specific recommendations will be mentioned later
263 @node Git for the impatient
264 @subsection Git for the impatient
266 @advanced{The intent of this subsection is to get you working on lilypond as
267 soon as possible. If you want to learn about git, go read
268 @ref{Other Git documentation}.
270 Also, these instructions are designed to eliminate the most common
271 problems we have found in using git. If you already know git and
272 have a different way of working, great! Feel free to ignore the
273 advice in this subsection.}
276 Ok, so you've been using @command{lily-git.tcl} for a while, but
277 it's time to take the next step. Since our review process delays
278 patches by 60-120 hours, and you want to be able to work on other
279 stuff while your previous work is getting reviewed, you're going
280 to use @strong{branches}.
282 You can think of a branch as being a separate copy of the source
283 code. But don't worry about it.
285 @subsubheading Start work: make a new branch
287 Let's pretend you want to add a section to the Contributor's Guide
288 about using branches.
290 Start by updating the repository, then making a new branch. Call
291 the branch anything you want as long as the name starts with
292 @code{dev/}. Branch names that don't begin with @code{dev/} are
293 reserved for special things in lilypond.
297 git pull -r origin master
301 @subsubheading Switch to that branch
303 Nothing has happened to the files yet. Let's change into the new
304 branch. You can think of this as @qq{loading a file}, although in
305 this case it's really @qq{loading a directory and subdirectories
312 Your prompt now shows you that you're on the other branch:
315 gperciva@@LilyDev:~/lilypond-git (dev/cg)$
318 To be able to manage multiple lilypond issues at once, you'll need to switch
319 branches. You should have each lilypond issue on a separate branch.
320 Switching branches is easy:
324 git checkout origin/staging
325 git checkout origin/release/unstable
329 Branches that begin with @code{origin/} are part of the remote repository,
330 rather than your local repository, so when you check them out you get a
331 temporary local branch. You should never make changes directly on a
332 branch beginning with @code{origin/}. You get changes into the remote
333 repository by making them in local branches, and then pushing them to
334 @code{origin/staging} as described below.
336 @subsubheading Make your changes
338 Edit files, then commit them.
345 Remember how I said that switching to a branch was like
346 @qq{loading a directory}? Well, you've just @qq{saved a
347 directory}, so that you can @qq{load} it later.
349 @advanced{If you have used @command{cvs} or @command{svn}, you may
350 be very confused: those programs use @qq{commit} to mean
351 @qq{upload my changes to the shared source repository}.
352 Unfortunately, just to be different, @w{@command{git commit}}
353 means @qq{save my changes to the files}.}
355 When you create a new file, you need to add it to git, then commit it:
358 git add input/regression/avoid-crash-on-condition.ly
363 Edit more files. Commit them again. Edit yet more files, commit
364 them again. Go eat dinner. Switch to @code{master} so you can
365 play with the latest changes from other developers. Switch back
366 to your branch and edit some more. Commit those changes.
368 At this stage, don't worry about how many commits you have.
371 @subsubheading Save commits to external files
373 Branches are nerve-wracking until you get used to them. You can
374 save your hard work as individual @file{.patch} files. Be sure to
375 commit your changes first.
379 git format-patch master
382 I personally have between 4 and 20 of those files saved in a
383 special folder at any point in time. Git experts might laugh as
384 that behavior, but I feel a @emph{lot} better knowing that I've
388 @subsubheading Prepare your branch for review
390 After committing, you can update your branch with the latest master:
395 git pull -r origin master
401 Due to the speed of lilypond development, sometimes
402 @code{master} has changed so much that your branch can no
403 longer be applied to it. In that happens, you will have a merge
404 conflict. Stop for a moment to either cry or have a stiff drink,
405 then proceed to @ref{Merge conflicts}.
408 @subsubheading Upload your branch
410 Finally, you're finished your changes. Time to upload for review.
411 Make sure that you're on your branch, then upload:
419 @subsubheading Wait for reviews
421 While you're waiting for a countdown and reviews, go back to
422 master, make a @code{dev/doc-beams} branch, and start adding doc
423 suggestions from issue 12345 from the tracker. Or make a
424 @code{dev/page-breaks} and fix bug in page breaking. Or whatever.
425 Don't worry, your @code{dev/cg} is safe.
428 @subsubheading Combining commits (optional unless you have broken commits)
430 Does the history of your branch look good?
436 If you have a lot of commits on your branch, you might want to
437 combine some of them. Alternately, you may like your commits, but
438 want to edit the commit messages.
444 Follow instructions on the screen.
446 @warning{This step gives you the power to completely lose your
447 work. Make a backup of your commits by saving them to
448 @file{.patch} files before playing with this. If you do lose
449 your work, don't despair. You can get it back by using @code{git reflog}.
450 The use of @code{git reflog} is not covered here.}
452 @warning{If any of the commits on your branch represent partial work that will
453 not pass @var{make && make doc}, you @strong{must} squash these
454 commits into a working commit. Otherwise, your push will break staging
455 and will not be able to be merged to master. In general, you will
456 be safer to have one commit per push.}
459 @subsubheading Push to staging
461 When you've got the coveted @code{Patch-push} status, time to
466 git rebase origin/staging dev/cg~0
470 @warning{Do not skip the @command{gitk} step; a quick 5-second
471 check of the visual history can save a great deal of frustration
472 later on. You should see a set of your commits that are ahead of
473 @code{origin/staging}, with no label for the top commit -- only a
476 @warning{If @code{origin/staging} and @code{origin/master} are the
477 same commit, your branch (@code{dev/cg} in the example) will also
478 be at the top of the @code{gitk} tree. This is normal.}
480 If everything looks good, push it:
483 git push origin HEAD:staging
486 Then change back to your working branch:
492 @warning{It is a best practice to avoid rebasing any of your branches
493 to @code{origin/staging}. If @code{origin/staging} is broken, it
494 will be deleted and rebuilt. If you have rebased one of your branches
495 to @code{origin/staging}, the broken commits can end up in your branch.
496 The commands given above do the rebase on a temporary branch, and avoid
497 changing your working branch.}
500 @subsubheading Delete your branch (safe)
502 After a few hours, if there's nothing wrong with your branch, it
503 should be automatically moved to @code{origin/master}. Update,
504 then try removing your branch:
508 git pull -r origin master
512 The last command will fail if the contents of @code{dev/cg} are
513 not present in @code{origin/master}.
516 @subsubheading Delete your branch (UNSAFE)
518 @c don't give explicit commands here -- this is too dangerous to copy and paste
519 Sometimes everything goes wrong. If you want to remove a branch even though
520 it will cause your work to be lost (that is, if the contents of @code{dev/cg}
521 are @strong{not} present in master), follow the instructions in @qq{Delete
522 your branch (safe)}, but replace the @code{-d} on the final line with
526 @node Other repositories
527 @subsection Other repositories
529 We have a few other code repositories.
533 * Grand Unified Builder (GUB)::
535 * yet more repositories::
539 @unnumberedsubsubsec lilypond-extra
541 There is a separate repository for general administrative scripts,
542 as well as pictures and media files for the website. People
543 interested in working on the website should download this
544 repository, and set their @code{$LILYPOND_WEB_MEDIA_GIT}
545 environment variable to point to that repository.
548 @uref{https://github.com/gperciva/lilypond-extra}
551 To configure an environment variable in bash (the default for most
552 GNU/Linux distributions),
555 export LILYPOND_WEB_MEDIA_GIT=$HOME/dir/of/lilypond-extra/
558 Be aware that @code{lilypond-extra} is the definitive source for some binary
559 files - in particular PDF versions of papers concerning LilyPond. To add
560 further PDFs of this sort, all that is necessary is to add the PDF to
561 @code{lilypond-extra} and then add a reference to it in the documentation. The
562 file will then be copied to the website when @code{make website} is run.
564 However, pictures that are also used in the documentation build are mastered in
565 the main git repository. If any of these is changed, it should be updated in
566 git, and then the updates copied to @code{lilypond-extra}.
568 @node Grand Unified Builder (GUB)
569 @unnumberedsubsubsec Grand Unified Builder (GUB)
571 Another item of interest might be the Grand Unified Builder, our
572 cross-platform building tool. Since it is used by other projects as
573 well, it is not stored in our gub repository. For more info, see
574 @uref{http://lilypond.org/gub}.
576 There are two locations for this repository: the version being used to
577 build lilypond, which is at
580 @uref{http://github.com/gperciva/gub}
583 and the original version by Jan Nieuwenhuizen, kept at
586 @uref{http://github.com/janneke/gub}
591 @unnumberedsubsubsec lilypad
593 Our binary releases on MacOS X and Windows contain a lightweight
594 text editor. This code is here:
597 https://github.com/gperciva/lilypad
601 @node yet more repositories
602 @unnumberedsubsubsec yet more repositories
604 There are a few other repositories floating around, which will
605 hopefully be documented in the near future.
608 @node Downloading remote branches
609 @subsection Downloading remote branches
611 @warning{contains obsolete + misleading info}
614 * Organization of remote branches::
615 * LilyPond repository sources::
616 * Downloading individual branches::
617 * Downloading all remote branches::
622 @node Organization of remote branches
623 @unnumberedsubsubsec Organization of remote branches
626 The main LilyPond repository is organized into @emph{branches} to
627 facilitate development. These are often called @emph{remote}
628 branches to distinguish them from @emph{local} branches you might
629 create yourself (see @ref{Using local branches}).
631 The @code{master} branch contains all the source files used to
632 build LilyPond, which includes the program itself (both stable and
633 development releases), the documentation (and its translations),
634 and the website. Generally, the @code{master} branch is expected
635 to compile successfully.
637 The @code{translation} branch is a side branch that
638 allows translators to work without needing to worry about
639 compilation problems. Periodically, the Translation Meister
640 (after verifying that it doesn't break compilation), will
641 @emph{merge} this branch into @code{staging} to incorporate
642 recent translations. Similarly, the @code{master} branch is
643 usually merged into the @code{translation} branch after
644 significant changes to the English documentation. See
645 @ref{Translating the documentation} for details.
648 @node LilyPond repository sources
649 @unnumberedsubsubsec LilyPond repository sources
652 The recommended source for downloading a copy of the main
656 git://git.sv.gnu.org/lilypond.git
659 However, if your internet router filters out connections using the
660 GIT protocol, or if you experience difficulty connecting via GIT,
661 you can try these other sources:
664 ssh://git.sv.gnu.org/srv/git/lilypond.git
665 http://git.sv.gnu.org/r/lilypond.git
668 The SSH protocol can only be used if your system is properly set
669 up to use it. Also, the HTTP protocol is slowest, so it should
670 only be used as a last resort.
673 @node Downloading individual branches
674 @unnumberedsubsubsec Downloading individual branches
676 @warning{obsolete, should be deleted!}
679 Once you have initialized an empty Git repository on your system
680 (see @ref{Initializing a repository}), you can download a remote
681 branch into it. Make sure you know which branch you want to start
684 To download the @code{master} branch, enter the following:
687 git remote add -ft master -m master \
688 origin git://git.sv.gnu.org/lilypond.git/
691 To download the @code{translation} branch, enter:
694 git remote add -ft translation -m \
695 translation origin git://git.sv.gnu.org/lilypond.git/
698 The @command{git@tie{}remote@tie{}add} process could take up to
699 ten minutes, depending on the speed of your connection. The
700 output will be something like this:
704 remote: Counting objects: 235967, done.
705 remote: Compressing objects: 100% (42721/42721), done.
706 remote: Total 235967 (delta 195098), reused 233311 (delta 192772)
707 Receiving objects: 100% (235967/235967), 68.37 MiB | 479 KiB/s, done.
708 Resolving deltas: 100% (195098/195098), done.
709 From git://git.sv.gnu.org/lilypond
710 * [new branch] master -> origin/master
711 From git://git.sv.gnu.org/lilypond
712 * [new tag] flower/1.0.1 -> flower/1.0.1
713 * [new tag] flower/1.0.10 -> flower/1.0.10
715 * [new tag] release/2.9.6 -> release/2.9.6
716 * [new tag] release/2.9.7 -> release/2.9.7
719 When @command{git@tie{}remote@tie{}add} is finished, the remote
720 branch should be downloaded into your repository---though not yet
721 in a form that you can use. In order to browse the source code
722 files, you need to @emph{create} and @emph{checkout} your own
723 local branch. In this case, however, it is easier to have Git
724 create the branch automatically by using the @command{checkout}
725 command on a non-existent branch. Enter the following:
728 git checkout -b @var{branch} origin/@var{branch}
732 where @code{@var{branch}} is the name of your tracking branch,
733 either @code{master} or @code{translation}.
735 Git will issue some warnings; this is normal:
738 warning: You appear to be on a branch yet to be born.
739 warning: Forcing checkout of origin/master.
740 Branch master set up to track remote branch master from origin.
744 By now the source files should be accessible---you should be able
745 to edit any files in the @file{$LILYPOND_GIT} directory using a
746 text editor of your choice. But don't start just yet! Before
747 editing any source files, learn how to keep your changes organized
748 and prevent problems later---read @ref{Basic Git procedures}.
750 @subsubheading Technical Details
752 The @command{git@tie{}remote@tie{}add} command should add some
753 lines to your local repository's @file{.git/config} file:
757 url = git://git.sv.gnu.org/lilypond.git/
758 fetch = +refs/heads/master:refs/remotes/origin/master
762 @node Downloading all remote branches
763 @unnumberedsubsubsec Downloading all remote branches
766 To download all remote branches at once, you can @command{clone}
767 the entire repository:
770 git clone git://git.sv.gnu.org/lilypond.git
775 @unnumberedsubsubsec Other branches
777 Most contributors will never need to touch the other branches. If
778 you wish to do so, you will need more familiarity with Git; please
779 see @ref{Other Git documentation}.
782 @item @code{dev/XYZ}:
783 These branches are for individual developers. They store code
784 which is not yet stable enough to be added to the @code{master}
787 @item @code{stable/XYZ}:
788 The branches are kept for archival reasons.
790 @item @code{archive/XYZ}:
791 The branches are kept for archival reasons.
796 @node Basic Git procedures
797 @section Basic Git procedures
801 * The Git contributor's cycle::
802 * Pulling and rebasing::
803 * Using local branches::
804 * Commits and patches::
808 @node The Git contributor's cycle
809 @subsection The Git contributor's cycle
812 Here is a simplified view of the contribution process on Git:
816 Update your local repository by @emph{pulling} the most recent
817 updates from the remote repository.
820 Edit source files within your local repository's @emph{working
824 @emph{Commit} the changes you've made to a local @emph{branch}.
827 Generate a @emph{patch} to share your changes with the developers.
831 @node Pulling and rebasing
832 @subsection Pulling and rebasing
835 When developers push new patches to the @code{git.sv.gnu.org}
836 repository, your local repository is @strong{not} automatically
837 updated. It is important to keep your repository up-to-date by
838 periodically @emph{pulling} the most recent @emph{commits} from
839 the remote branch. Developers expect patches to be as current as
840 possible, since outdated patches require extra work before they
843 Occasionally you may need to rework some of your own modifications
844 to match changes made to the remote branch (see @ref{Resolving
845 conflicts}), and it's considerably easier to rework things
846 incrementally. If you don't update your repository along the way,
847 you may have to spend a lot of time resolving branch conflicts and
848 reconfiguring much of the work you've already done.
850 Fortunately, Git is able to resolve certain types of branch
851 conflicts automatically with a process called @emph{rebasing}.
852 When rebasing, Git tries to modify your old commits so they appear
853 as new commits (based on the latest updates). For a more involved
854 explanation, see the @command{git-rebase} man page.
856 To pull without rebasing (recommended for translators), use the
860 git pull # recommended for translators
863 If you're tracking the remote @code{master} branch, you should add
864 the @option{-r} option (short for @option{--rebase}) to keep commits
865 on your local branch current:
868 git pull -r # use with caution when translating
871 If you don't edit translated documentation and don't want to type
872 @option{-r} every time, configure the master branch to rebase by
873 default with this command:
876 git config branch.master.rebase true
879 If pull fails because of a message like
882 error: Your local changes to 'Documentation/learning/tutorial.itely'
883 would be overwritten by merge. Aborting.
890 Documentation/learning/tutorial.itely: needs update
891 refusing to pull with rebase: your working tree is not up-to-date
895 it means that you have modified some files in you working tree
896 without committing changes (see @ref{Commits and patches}); you
897 can use the @command{git@tie{}stash} command to work around this:
900 git stash # save uncommitted changes
901 git pull -r # pull using rebase (translators omit "-r")
902 git stash pop # reapply previously saved changes
905 Note that @command{git@tie{}stash@tie{}pop} will try to apply a
906 patch, and this may create a conflict. If this happens, see
907 @ref{Resolving conflicts}.
909 TODO: I think the next paragraph is confusing. Perhaps prepare
910 the reader for new terms `committish' and `head'? -mp
912 @warning{translators and documentation editors, if you have
913 changed committishes in the head of translated files using commits
914 you have not yet pushed to @code{git.sv.gnu.org}, please do not
915 rebase. If you want to avoid wondering whether you should rebase
916 each time you pull, please always use committishes from master
917 and/or translation branch on @code{git.sv.gnu.org}, which
918 in particular implies that you must push your changes to
919 documentation except committishes updates (possibly after having
920 rebased), then update the committishes and push them.}
922 TODO: when committishes automatic conditional update have been
923 tested and documented, append the following to the warning above:
924 Note that using update-committishes make target generally touches
927 @subsubheading Technical details
929 The @command{git@tie{}config} command mentioned above adds the
930 line @code{rebase = true} to the master branch in your local
931 repository's @file{.git/config} file:
936 merge = refs/heads/master
941 @node Using local branches
942 @subsection Using local branches
946 * Creating and removing branches::
947 * Listing branches and remotes::
948 * Checking out branches::
953 @node Creating and removing branches
954 @unnumberedsubsubsec Creating and removing branches
957 Local branches are useful when you're working on several different
958 projects concurrently. To create a new branch, enter:
961 git branch @var{name}
964 To delete a branch, enter:
967 git branch -d @var{name}
970 Git will ask you for confirmation if it sees that data would be
971 lost by deleting the branch. Use @option{-D} instead of @option{-d}
972 to bypass this. Note that you cannot delete a branch if it is
973 currently checked out.
976 @node Listing branches and remotes
977 @unnumberedsubsubsec Listing branches and remotes
979 You can get the exact path or URL of all remote branches by
986 To list Git branches on your local repositories, run
989 git branch # list local branches only
990 git branch -r # list remote branches
991 git branch -a # list all branches
995 @node Checking out branches
996 @unnumberedsubsubsec Checking out branches
998 To know the currently checked out branch, i.e. the branch whose
999 source files are present in your working tree, read the first line
1007 The currently checked out branch is also marked with an asterisk
1008 in the output of @command{git branch}.
1010 You can check out another branch @code{@var{other_branch}}, i.e.
1011 check out @code{@var{other_branch}} to the working tree, by
1015 git checkout @var{other_branch}
1018 Note that it is possible to check out another branch while having
1019 uncommitted changes, but it is not recommended unless you know
1020 what you are doing; it is recommended to run @command{git status}
1021 to check this kind of issue before checking out another branch.
1023 @node Merging branches
1024 @unnumberedsubsubsec Merging branches
1026 To merge branch @code{@var{foo}} into branch @code{@var{bar}},
1027 i.e. to @qq{add} all changes made in branch @code{@var{foo}} to
1028 branch @code{@var{bar}}, run
1031 git checkout @var{bar}
1035 If any conflict happens, see @ref{Resolving conflicts}.
1037 There are common usage cases for merging: as a translator, you will
1038 often want the Translations meister to merge @code{master} into
1039 @code{translation}; on the other hand, the Translations meister wants
1040 to merge @code{translation} into @code{staging} whenever he has
1041 checked that @code{translation} builds successfully.
1044 @node Commits and patches
1045 @subsection Commits and patches
1049 * Understanding commits::
1053 * Uploading a patch for review::
1057 @node Understanding commits
1058 @unnumberedsubsubsec Understanding commits
1060 Technically, a @emph{commit} is a single point in the history of a
1061 branch, but most developers use the term to mean a @emph{commit
1062 object}, which stores information about a particular revision. A
1063 single commit can record changes to multiple source files, and
1064 typically represents one logical set of related changes (such as a
1065 bug-fix). You can list the ten most recent commits in your
1066 current branch with this command:
1069 git log -10 --oneline
1072 If you're using an older version of Git and get an @q{unrecognized
1073 argument} error, use this instead:
1076 git log -10 --pretty=oneline --abbrev-commit
1079 More interactive lists of the commits on the remote @code{master}
1080 branch are available at
1081 @uref{http://git.sv.gnu.org/gitweb/?p=lilypond.git;a=shortlog} and
1082 @uref{http://git.sv.gnu.org/cgit/lilypond.git/log/}.
1085 @node Making commits
1086 @unnumberedsubsubsec Making commits
1089 Once you have modified some source files in your working
1090 directory, you can make a commit with the following procedure:
1094 Make sure you've configured Git properly (see @ref{Configuring
1095 Git}). Check that your changes meet the requirements described in
1096 @ref{Code style} and/or @ref{Documentation policy}. For advanced
1097 edits, you may also want to verify that the changes don't break
1098 the compilation process.
1101 Run the following command:
1108 to make sure you're on the right branch, and to see which files
1109 have been modified, added or removed, etc. You may need to tell
1110 Git about any files you've added by running one of these:
1113 git add @var{file} # add untracked @var{file} individually
1114 git add . # add all untracked files in current directory
1118 After @command{git@tie{}add}, run @command{git@tie{}status} again
1119 to make sure you got everything. You may also need to modify
1123 Preview the changes about to be committed (to make sure everything
1131 The @code{HEAD} argument refers to the most recent commit on the
1132 currently checked-out branch.
1135 Generate the commit with:
1142 The @option{-a} is short for @option{--all} which includes modified
1143 and deleted files, but only those newly created files that have
1144 previously been added.
1149 @node Commit messages
1150 @unnumberedsubsubsec Commit messages
1153 When you run the @command{git@tie{}commit@tie{}-a} command, Git
1154 automatically opens the default text editor so you can enter a
1155 @emph{commit message}. If you find yourself in a foreign editing
1156 environment, you're probably in @command{vi} or @command{vim}. If
1157 you want to switch to an editor you're more familiar with, quit by
1158 typing @code{:q!} and pressing @code{<Enter>}. See
1159 @ref{Configuring Git} for instructions on changing the default
1162 In any case, Git will open a text file for your commit message
1163 that looks like this:
1167 # Please enter the commit message for your changes. Lines starting
1168 # with '#' will be ignored, and an empty message aborts the commit.
1170 # Changes to be committed:
1171 # (use "git reset HEAD <file>..." to unstage)
1173 # modified: working.itexi
1177 Your commit message should begin with a one-line summary
1178 describing the change (no more than 50 characters long), and if
1179 necessary a blank line followed by several lines giving the
1182 @c $ git log -1 --pretty=medium 4d6f1e5
1184 Doc: add Baerenreiter and Henle solo cello suites
1186 Added comparison of solo cello suite engravings to new essay with
1187 high-res images, fixed cropping on Finale example.
1190 Commit messages often start with a short prefix describing the
1191 general location of the changes. If a commit affects the
1192 documentation in English (or in several languages simultaneously)
1193 the commit message should be prefixed with @qq{Doc:@tie{}}. If
1194 the commit affects only one of the translations, the commit
1195 message should be prefixed with @qq{Doc-@var{**}:@tie{}}, where
1196 @var{**} is the two-letter language code. Commits that affect the
1197 website should use @qq{Web:@tie{}} for English, and
1198 @qq{Web-@var{**}:@tie{}} for the other languages. Also, changes
1199 to a single file are often prefixed with the name of the file
1200 involved. Visit the links listed in @ref{Understanding commits}
1204 @node Making patches
1205 @unnumberedsubsubsec Making patches
1207 If you want to share your changes with other contributors and
1208 developers, you need to generate @emph{patches} from your commits.
1209 We prefer it if you follow the instructions in
1210 @ref{Uploading a patch for review}. However, we present an
1211 alternate method here.
1213 You should always run @command{git@tie{}pull@tie{}-r} (translators
1214 should leave off the @option{-r}) before doing this to ensure that
1215 your patches are as current as possible.
1217 Once you have made one or more commits in your local repository,
1218 and pulled the most recent commits from the remote branch, you can
1219 generate patches from your local commits with the command:
1222 git format-patch origin
1225 The @code{origin} argument refers to the remote tracking branch at
1226 @code{git.sv.gnu.org}. This command generates a separate patch
1227 for each commit that's in the current branch but not in the remote
1228 branch. Patches are placed in the current working directory and
1229 will have names that look something like this:
1232 0001-Doc-Fix-typos.patch
1233 0002-Web-Remove-dead-links.patch
1237 Send an email (must be less than 64 KB) to
1238 @email{lilypond-devel@@gnu.org} briefly explaining your work, with
1239 the patch files attached. Translators should send patches to
1240 @email{translations@@lilynet.net}. After your patches are
1241 reviewed, the developers may push one or more of them to the main
1242 repository or discuss them with you.
1245 @node Uploading a patch for review
1246 @unnumberedsubsubsec Uploading a patch for review
1248 Any non-trivial change should be uploaded to our @qq{Rietveld}
1249 code review website:
1252 @uref{http://codereview.appspot.com/}
1255 @subsubheading @command{git-cl} install
1257 LilyDev users should skip over these @q{install} instructions.
1262 Install @command{git-cl} by entering:
1265 git clone https://github.com/gperciva/git-cl.git
1268 If that command fails for some reason, try this instead:
1271 git clone git://github.com/gperciva/git-cl.git
1275 Add the @file{git-cl/} directory to your PATH,
1276 or create a symbolic link to the @command{git-cl}
1277 and @command{upload.py} scripts in one of your PATH
1278 directories (such as @file{$HOME/bin}).
1280 In Ubuntu (and LilyDev), you can add directories to PATH
1281 by adding this line to a hidden file @file{.bashrc},
1282 located in your home directory:
1285 PATH=~/type-here-directory-containing-git-cl:"$@{PATH@}"
1290 @subsubheading @command{git-cl} configuration
1292 LilyDev users should perform these @q{configuration} instructions.
1296 You must have a google account; please create one if you do not
1299 Note that a google account does not need to be a gmail account; you can
1300 use any email address for your google account when you sign up.
1303 Move into the top source directory and then configure @command{git
1304 cl} with the following commands:
1311 For the @qq{Rietveld server} question, the default value
1312 (@qq{codereview.appspot.com}) should be accepted by
1313 answering with a newline (CR).
1315 The @qq{CC list} question should be answered with:
1318 lilypond-devel@@gnu.org
1321 The @qq{Tree status URL} value should be left blank. So should
1322 the @qq{ViewVC URL} value, since it is used by @command{git cl
1323 dcommit} which is only for repositories which use @command{git
1324 svn} (LilyPond doesn't).
1328 @subsubheading Uploading patch set
1330 @warning{Unless you are familiar with branches, only work on one
1331 set of changes at once.}
1333 There are two methods, depending on your git setup.
1337 @strong{Master branch}: (easy option, and used in @command{lily-git.tcl})
1339 If you added your patch to @code{master}, then:
1343 git cl upload origin/master
1346 @c Mention staging here?
1347 If you have git push ability, make sure that you @emph{remove}
1348 your patch (with @command{git rebase} or @command{git reset})
1349 before pushing other stuff.
1351 @c don't make this one an @example; we don't want to make it easy
1352 @c for people to use this accidently
1353 Notifications of patches are automatically added to our issue
1354 tracker to reduce the chance of patches getting lost. To suppress
1355 this (not recommended), add the @code{-n / --no-code-issue}
1359 @strong{Separate branch}: (complicated option)
1361 Ensure your changes are committed in a separate branch, which
1362 should differ from the reference branch to be used by just the
1363 changes to be uploaded. If the reference branch is to be
1364 origin/master, ensure this is up-to-date. If necessary, use git
1365 rebase to rebase the branch containing the changes to the head of
1366 origin/master. Finally, check out branch with the changes and
1370 git cl upload <reference SHA1 ID>
1374 where <reference SHA1 ID> is the SHA1 ID of the commit to be used
1375 as a reference source for the patch. Generally, this will be the
1376 SHA1 ID of origin/master, and in that case the command:
1379 git cl upload origin/master
1387 After prompting for your Google email address and password, the
1388 patch set will be posted to Rietveld, and you will be given a URL
1391 @warning{Some installations of git-cl fail when uploading a patch
1392 with certain filename extensions. If this happens, it can
1393 generally be fixed by editing the list of exceptions at top of
1396 @subsubheading Announcing your patch set
1398 You should then announce the patch by logging into the code review
1399 issue webpage and using @qq{Publish + Mail Comments} to add a
1400 (mostly bogus) comment to your issue. The text of your comment
1401 will be sent to our developer mailing list.
1403 @warning{There is no automatic notification of a new patch; you
1404 must add a comment yourself.}
1406 @subsubheading Revisions
1408 As revisions are made in response to comments, successive patch sets
1409 for the same issue can be uploaded by reissuing the git-cl command
1410 with the modified branch checked out.
1412 Sometimes in response to comments on revisions, the best way to
1413 work may require creation of a new branch in git. In order to
1414 associate the new branch with an existing Rietveld issue,
1415 the following command can be used:
1418 git cl issue issue-number
1422 where @code{issue-number} is the number of the existing Rietveld
1425 @subsubheading Resetting git cl
1427 If @command{git cl} becomes confused, you can @qq{reset} it by
1434 @subsubheading Wait for a countdown
1436 Your patch will be available for reviews for the next few hours or
1437 days. Three times a week, patches with no known problems are
1438 gathered into a @qq{patch countdown} and their status changed to
1439 @code{patch-countdown}. The countdown is a 48-hour waiting period
1440 in which any final reviews or complaints should be made.
1442 During the countdown, your patch may be set to
1443 @code{patch-needs_work}, indicating that you should fix something
1444 (or at least discuss why the patch needs no modification). If no
1445 problems are found, the patch will be set to @code{patch-push}.
1447 Once a patch has @code{patch-push}, it should be sent to your
1448 mentor for uploading. If you have git push ability, look at
1449 @ref{Pushing to staging}.
1452 @node Advanced Git procedures
1453 @section Advanced Git procedures
1456 @warning{This section is not necessary for normal contributors;
1457 these commands are presented for information for people interested
1458 in learning more about git.}
1460 It is possible to work with several branches on the same local Git
1461 repository; this is especially useful for translators who may have
1462 to deal with both @code{translation} and a stable branch,
1463 e.g. @code{stable/2.12}.
1465 Some Git commands are introduced first, then a workflow with
1466 several Git branches of LilyPond source code is presented.
1471 * Advanced Git concepts::
1472 * Resolving conflicts::
1473 * Reverting all local changes::
1474 * Working with remote branches::
1476 * Applying remote patches::
1477 * Sending and receiving patches via email::
1478 * Cleaning up multiple patches::
1480 * Pushing to staging::
1484 @node Merge conflicts
1485 @subsection Merge conflicts
1487 To be filled in later, and/or moved to a different section. I
1488 just wanted to make sure that I had a stub ready somewhere.
1491 @node Advanced Git concepts
1492 @subsection Advanced Git concepts
1495 A bit of Git vocabulary will be explained below. The following is
1496 only introductory; for a better understanding of Git concepts, you
1497 may wish to read @ref{Other Git documentation}.
1499 The @code{git@tie{}pull@tie{}origin} command above is just a
1500 shortcut for this command:
1503 git pull git://git.sv.gnu.org/lilypond.git/ @var{branch}:origin/@var{branch}
1507 where @code{@var{branch}} is typically @code{master} or
1508 @code{translation}; if you do not know or remember, see
1509 @ref{Downloading remote branches} to remember which commands you
1510 issued or which source code you wanted to get.
1512 A @emph{commit} is a set of changes made to the sources; it also
1513 includes the committish of the parent commit, the name and e-mail
1514 of the @emph{author} (the person who wrote the changes), the name
1515 and e-mail of the @emph{committer} (the person who brings these
1516 changes into the Git repository), and a commit message.
1518 A @emph{committish} is the SHA1 checksum of a commit, a number
1519 made of 40 hexadecimal digits, which acts as the internal unique
1520 identifier for this commit. To refer to a particular revision,
1521 don't use vague references like the (approximative) date, simply
1522 copy and paste the committish.
1524 A @emph{branch} is nothing more than a pointer to a particular
1525 commit, which is called the @emph{head} of the branch; when
1526 referring to a branch, one often actually thinks about its head
1527 and the ancestor commits of the head.
1529 Now we will explain the two last commands you used to get the
1530 source code from Git---see @ref{Downloading individual branches}.
1533 git remote add -ft @var{branch} -m @var{branch} \
1534 origin git://git.sv.gnu.org/lilypond.git/
1536 git checkout -b @var{branch} origin/@var{branch}
1539 The @command{git@tie{}remote} has created a branch called
1540 @code{origin/@var{branch}} in your local Git repository. As this
1541 branch is a copy of the remote branch web from git.sv.gnu.org
1542 LilyPond repository, it is called a @emph{remote branch}, and is
1543 meant to track the changes on the branch from git.sv.gnu.org: it
1544 will be updated every time you run
1545 @command{git@tie{}pull@tie{}origin} or
1546 @command{git@tie{}fetch@tie{}origin}.
1548 The @command{git@tie{}checkout} command has created a branch named
1549 @code{@var{branch}}. At the beginning, this branch is identical
1550 to @code{origin/@var{branch}}, but it will differ as soon as you
1551 make changes, e.g. adding newly translated pages or editing some
1552 documentation or code source file. Whenever you pull, you merge
1553 the changes from @code{origin/@var{branch}} and
1554 @code{@var{branch}} since the last pulling. If you do not have
1555 push (i.e. @qq{write}) access on git.sv.gnu.org, your
1556 @code{@var{branch}} will always differ from
1557 @code{origin/@var{branch}}. In this case, remember that other
1558 people working like you with the remote branch @code{@var{branch}}
1559 of git://git.sv.gnu.org/lilypond.git/ (called
1560 @code{origin/@var{branch}} on your local repository) know nothing
1561 about your own @code{@var{branch}}: this means that whenever you
1562 use a committish or make a patch, others expect you to take the
1563 latest commit of @code{origin/@var{branch}} as a reference.
1565 Finally, please remember to read the man page of every Git command
1566 you will find in this manual in case you want to discover
1567 alternate methods or just understand how it works.
1570 @node Resolving conflicts
1571 @subsection Resolving conflicts
1574 Occasionally an update may result in conflicts -- this happens
1575 when you and somebody else have modified the same part of the same
1576 file and git cannot figure out how to merge the two versions
1577 together. When this happens, you must manually merge the two
1580 If you need some documentation to understand and resolve
1581 conflicts, see paragraphs @emph{How conflicts are presented} and
1582 @emph{How to resolve conflicts} in @command{git merge} man page.
1584 If all else fails, you can follow the instructions in
1585 @ref{Reverting all local changes}. Be aware that this eliminates
1586 any changes you have made!
1589 @node Reverting all local changes
1590 @subsection Reverting all local changes
1592 Sometimes git will become hopelessly confused, and you just want
1593 to get back to a known, stable state. This command destroys any
1594 local changes you have made in the currently checked-out branch,
1595 but at least you get back to the current online version:
1598 git reset --hard origin/master
1602 @node Working with remote branches
1603 @subsection Working with remote branches
1606 @subsubheading Fetching new branches from git.sv.gnu.org
1608 To fetch and check out a new branch named @code{@var{branch}} on
1609 git.sv.gnu.org, run from top of the Git repository
1612 git config --add remote.origin.fetch \
1613 +refs/heads/@var{branch}:refs/remotes/origin/@var{branch}
1615 git checkout --track -b @var{branch} origin/@var{branch}
1618 After this, you can pull @code{@var{branch}} from git.sv.gnu.org
1625 Note that this command generally fetches all branches you added
1626 with @command{git@tie{}remote@tie{}add} (when you initialized the
1627 repository) or @command{git@tie{}config@tie{}--add}, i.e. it
1628 updates all remote branches from remote @code{origin}, then it
1629 merges the remote branch tracked by the current branch into the
1630 current branch. For example, if your current branch is
1631 @code{master}, @code{origin/master} will be merged into
1635 @subsubheading Local clones, or having several working trees
1637 If you play with several Git branches, e.g. @code{master},
1638 @code{translation}, @code{stable/2.12}), you may want to
1639 have one source and build tree for each branch; this is possible
1640 with subdirectories of your local Git repository, used as local
1641 cloned subrepositories. To create a local clone for the branch
1642 named @code{@var{branch}}, run
1645 git checkout @var{branch}
1646 git clone -lsn . @var{subdir}
1651 Note that @code{@var{subdir}} must be a directory name which does
1652 not already exist. In @code{@var{subdir}}, you can use all Git
1653 commands to browse revisions history, commit and uncommit changes;
1654 to update the cloned subrepository with changes made on the main
1655 repository, cd into @code{@var{subdir}} and run
1656 @command{git@tie{}pull}; to send changes made on the subrepository
1657 back to the main repository, run @command{git@tie{}push} from
1658 @code{@var{subdir}}. Note that only one branch (the currently
1659 checked out branch) is created in the subrepository by default; it
1660 is possible to have several branches in a subrepository and do
1661 usual operations (checkout, merge, create, delete...) on these
1662 branches, but this possibility is not detailed here.
1664 When you push @code{@var{branch}} from @code{@var{subdir}} to the
1665 main repository, and @code{@var{branch}} is checked out in the
1666 main repository, you must save uncommitted changes (see
1667 @command{git@tie{}stash}) and do
1668 @command{git@tie{}reset@tie{}--hard} in the main repository in
1669 order to apply pushed changes in the working tree of the main
1677 The commands above don't only bring you the latest version of the
1678 sources, but also the full history of revisions (revisions, also
1679 called commits, are changes made to the sources), stored in the
1680 @file{.git} directory. You can browse this history with
1683 git log # only shows the logs (author, committish and commit message)
1684 git log -p # also shows diffs
1685 gitk # shows history graphically
1688 @warning{The @code{gitk} command may require a separate
1689 @code{gitk} package, available in the appropriate distribution's
1693 @node Applying remote patches
1694 @subsection Applying remote patches
1697 TODO: Explain how to determine if a patch was created with
1698 @code{git@tie{}format-patch}.
1700 Well-formed git patches created with @code{git@tie{}format-patch}
1701 should be committed with the following command:
1707 Patches created without @code{git@tie{}format-patch} can be
1708 applied in two steps. The first step is to apply the patch to the
1709 working tree and the index:
1712 git apply --index @var{patch}
1716 The second step is to commit the changes and give credit to the
1717 author of the patch. This can be done with the following command:
1720 git commit --author="@var{John Smith} <@var{john@@example.com}>"
1723 Please note that using the @code{--index} option for patching is quite
1724 important here and @emph{cannot} reliably be replaced by using the
1725 @code{-a} option when committing: that would only commit files from the
1726 working tree that are already registered with git, so every file that
1727 the patch actually @emph{adds}, like a regtest for a fixed bug, would
1728 get lost. For the same reason, you should not use the git-independent
1729 @samp{patch} program for applying patches.
1731 @node Sending and receiving patches via email
1732 @subsection Sending and receiving patches via email
1735 The default @code{x-diff} MIME type associated with patch files
1736 (i.e., files whose name ends in @code{.patch}) means that the
1737 encoding of line endings may be changed from UNIX to DOS format
1738 when they are sent as attachments. Attempting to apply such an
1739 inadvertently altered patch will cause git to fail with a message
1740 about @q{whitespace errors}.
1742 The solution to such problems is surprisingly simple---just change
1743 the default file extension of patches generated by git to end in
1744 @code{.txt}, for example:
1747 git config format.suffix '.patch.txt'
1750 This should cause email programs to apply the correct base64
1751 encoding to attached patches.
1753 If you receive a patch with DOS instead of UNIX line-endings, it
1754 can be converted back using the @code{dos2unix} utility.
1756 Lots of useful information on email complications with patches is
1757 provided on the Wine wiki at
1758 @uref{http://wiki.winehq.org/GitWine}.
1761 @node Cleaning up multiple patches
1762 @subsection Cleaning up multiple patches
1764 If you have been developing on your own branch for a while, you
1765 may have more commmits than is really sensible. To revise your
1766 work and condense commits, use:
1769 git rebase origin/master
1770 git rebase -i origin/master
1773 @warning{Be a bit cautious -- if you completely remove commits
1774 during the interactive session, you will... err... completely
1775 remove those commits.}
1779 @subsection Commit access
1781 Most contributors are not able to commit patches directly to the
1782 main repository---only members of the LilyPond development team
1783 have @emph{commit access}. If you are a contributor and are
1784 interested in joining the development team, contact the Project
1785 Manager through the mailing list
1786 (@email{lilypond-devel@@gnu.org}). Generally, only contributors
1787 who have already provided a number of patches which have been
1788 pushed to the main repository will be considered for membership.
1790 If you have been approved by the Project Manager, use the
1791 following procedure to obtain commit access:
1795 If you don't already have one, set up a Savannah user account at
1796 @uref{https://savannah.gnu.org/account/register.php}. If your web
1797 browser responds with an @qq{untrusted connection} message when
1798 you visit the link, follow the steps for including the CAcert root
1799 certificate in your browser, given at
1800 @uref{http://savannah.gnu.org/tls/tutorial/}.
1802 @warning{Savannah will silently put your username in lower-case --
1803 do not try to use capital letters.}
1807 After registering, if you are not logged in automatically, login
1808 at @uref{https://savannah.gnu.org/account/login.php}---this should
1809 take you to your @qq{my} page
1810 (@uref{https://savannah.gnu.org/my/}).
1814 Click on the @qq{My Groups} link to access the @qq{My Group
1815 Membership} page. From there, find the @qq{Request for Inclusion}
1816 box and search for @qq{LilyPond}. Among the search results, check
1817 the box labeled @qq{GNU LilyPond Music Typesetter} and write a
1818 brief (required) message for the Project Manager (@qq{Hey it's
1819 me!} should be fine).
1821 Note that you will not have commit access until the Project
1822 Manager activates your membership. Once your membership is
1823 activated, LilyPond should appear under the heading @qq{Groups I'm
1824 Contributor of} on your @qq{My Group Membership} page.
1828 Generate an SSH @q{rsa} key pair. Enter the following at the
1835 When prompted for a location to save the key, press <ENTER> to
1836 accept the default location (@file{~/.ssh/id_rsa}).
1838 Next you are asked to enter an optional passphrase. On most
1839 systems, if you use a passphrase, you will likely be prompted for
1840 it every time you use @command{git@tie{}push} or
1841 @command{git@tie{}pull}. You may prefer this since it can protect
1842 you from your own mistakes (like pushing when you mean to pull),
1843 though you may find it tedious to keep re-entering it.
1845 You can change/enable/disable your passphrase at any time with:
1848 ssh-keygen -f ~/.ssh/id_rsa -p
1851 Note that the GNOME desktop has a feature which stores your
1852 passphrase for you for an entire GNOME session. If you use a
1853 passphrase to @qq{protect you from yourself}, you will want to
1854 disable this feature, since you'll only be prompted once. Run the
1855 following command, then logout of GNOME and log back in:
1858 gconftool-2 --set -t bool \
1859 /apps/gnome-keyring/daemon-components/ssh false
1862 After setting up your passphrase, your private key is saved as
1863 @file{~/.ssh/id_rsa} and your public key is saved as
1864 @file{~/.ssh/id_rsa.pub}.
1868 Register your public SSH @q{rsa} key with Savannah. From the
1869 @qq{My Account Configuration} page, click on @qq{Edit SSH Keys},
1870 then paste the contents of your @file{~/.ssh/id_rsa.pub} file into
1871 one of the @qq{Authorized keys} text fields, and click
1874 Savannah should respond with something like:
1877 Success: Key #1 seen Keys registered
1882 Configure Git to use the SSH protocol (instead of the GIT
1883 protocol). From your local Git repository, enter:
1886 git config remote.origin.url \
1887 ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond.git
1891 replacing @var{user} with your Savannah username.
1895 After your membership has been activated and you've configured Git
1896 to use SSH, test the connection with:
1902 SSH should issue the following warning:
1905 The authenticity of host 'git.sv.gnu.org (140.186.70.72)' can't
1907 RSA key fingerprint is
1908 80:5a:b0:0c:ec:93:66:29:49:7e:04:2b:fd:ba:2c:d5.
1909 Are you sure you want to continue connecting (yes/no)?
1912 Make sure the RSA key fingerprint displayed matches the one above.
1913 If it doesn't, respond @qq{no} and check that you configured Git
1914 properly in the previous step. If it does match, respond
1915 @qq{yes}. SSH should then issue another warning:
1918 Warning: Permanently added 'git.sv.gnu.org,140.186.70.72' (RSA) to
1919 the list of known hosts.
1922 The list of known hosts is stored in the file
1923 @file{~/.ssh/known_hosts}.
1925 At this point, you are prompted for your passphrase if you have
1926 one, then Git will attempt a pull.
1928 If @command{git@tie{}pull@tie{}--verbose} fails, you should see
1929 error messages like these:
1932 Permission denied (publickey).
1933 fatal: The remote end hung up unexpectedly
1936 If you get the above error, you may have made a mistake when
1937 registering your SSH key at Savannah. If the key is properly
1938 registered, you probably just need to wait for the Savannah server
1939 to activate it. It usually takes a few minutes for the key to be
1940 active after registering it, but if it still doesn't work after an
1941 hour, ask for help on the mailing list.
1943 If @command{git@tie{}pull@tie{}--verbose} succeeds, the output
1944 will include a @q{From} line that shows @q{ssh} as the protocol:
1947 From ssh://git.sv.gnu.org/srv/git/lilypond
1950 If the protocol shown is not @q{ssh}, check that you configured
1951 Git properly in the previous step.
1955 Test your commit access with a dry run:
1957 @warning{Do not push directly to master; instead, push to staging.
1958 See @ref{Pushing to staging}.}
1961 git push --dry-run --verbose
1964 Note that recent versions of Git (Git 1.6.3 or later) will issue a
1965 big warning if the above command is used. The simplest solution
1966 is to tell Git to push all matching branches by default:
1969 git config push.default matching
1973 Then @code{git@tie{}push} should work as before. For more
1974 details, consult the @code{git@tie{}push} man page.
1978 Repeat the steps from generating an RSA key through to testing
1979 your commit access, for each machine from which you will be
1980 making commits, or you may simply copy the files from your
1981 local @file{~/.ssh} folder to the same folder on the other
1986 @subsubheading Technical details
1990 On Firefox, to view or remove the CAcert root certificate, go to:
1991 Edit > Preferences > Advanced > Encryption > View Certificates >
1992 Authorities > Certificate Name > Root CA > CA Cert Signing
1996 The @command{git@tie{}config} commands above should modify your
1997 local repository's @file{.git/config} file. These lines:
2001 url = git://git.sv.gnu.org/lilypond.git/
2005 should now be changed to:
2009 url = ssh://@var{user}@@git.sv.gnu.org/srv/git/lilypond.git
2013 where @var{user} is your login name on Savannah.
2017 @command{git@tie{}config@tie{}push.default@tie{}matching} command
2018 should add these lines to @file{.git/config}:
2027 Encryption protocols, including ssh, generally do not permit packet
2028 fragmentation to avoid introducing a point of insecurity. This
2029 means that the maximum packet size must not exceed the smallest
2030 MTU (Maximum Transmission Unit) set in the routers along the path.
2031 This smallest MTU is determined by a procedure during call set-up
2032 which relies on the transmission over the path of ICMP packets.
2033 If any of the routers in the path block ICMP packets this mechanism
2034 fails, resulting in the possibility of packets being transmitted
2035 which exceed the MTU of one of the routers. If this happens the
2036 packet is discarded, causing the ssh session to hang, timeout or
2037 terminate with the error message
2040 ssh: connect to host <host ip addr> port 22: Bad file number
2041 fatal: The remote end hung up unexpectedly
2044 depending on precisely when in the proceedings the first large
2045 packet is transmitted. Most routers on the internet have MTU
2046 set to 1500, but routers installed in homes to connect via
2047 broadband may use a slightly smaller MTU for efficient transmission
2048 over ATM. If this problem is encountered a possible work-around is
2049 to set the MTU in the local router to 1500.
2052 @node Pushing to staging
2053 @subsection Pushing to staging
2055 Do not push directly to the git @code{master} branch. Instead,
2056 push to @code{staging}.
2058 You will not see your patch on @code{origin/master} until some
2059 automatic tests have been run. These tests are run every couple
2060 of hours; please wait at least 12 hours before wondering if your
2061 patch has been lost. Note that you can check the commits on
2062 @code{origin/staging} by looking at the git web interface on
2065 It may happen occasionally that the staging branch breaks automated
2066 testing. In this case the automatic move of staging material to
2067 master gets halted in order to avoid broken material entering master.
2068 This is a safety net. Please do not try breaking out from it by
2069 adding fixes on top of staging: in that case the whole sequence will
2070 end up in master after all, defeating the purpose of the system. The
2071 proper fix usually involves rewriting the staging branch and is best
2072 left to core developers after discussion on the developer list.
2074 @subsubheading If your work is in a patch file
2076 Assuming that your patch is in a file called
2077 @file{0001-my-patch.patch}, and you are currently on git master,
2081 git checkout staging
2083 git am 0001-my-patch.patch
2085 git push origin staging
2089 @warning{Do not skip the @command{gitk} step; a quick 5-second
2090 check of the visual history can save a great deal of frustration
2091 later on. You should only see that @command{staging} is only 1
2092 commit ahead of @code{origin/staging}.}
2094 @subsubheading If your work is in a branch
2096 If you are working on branches and your work in is
2097 @code{my_branch_name}, then do:
2100 git checkout staging
2102 git merge my_branch_name
2104 git push origin staging
2107 @warning{Do not skip the @command{gitk} step; a quick 5-second
2108 check of the visual history can save a great deal of frustration
2109 later on. You should see that @code{staging} is only ahead of
2110 @code{origin/staging} by the commits from your branch.}
2114 @node Git on Windows
2115 @section Git on Windows
2117 @warning{We heavily recommend that development be done with our
2118 virtual machine @ref{LilyDev}.}
2120 @c Some of this may duplicate stuff in other sections
2121 @c But it is probably best for windows users to have it all together
2122 @c If necessary, clear this up later -td
2124 TODO: Decide what to do with this... Pare it down? Move
2125 paragraphs next to analogous Unix instructions? -mp
2127 @subsection Background to nomenclature
2129 Git is a system for tracking the changes made to source files by a
2130 distributed set of editors. It is designed to work without a
2131 master repository, but we have chosen to have a master repository
2132 for LilyPond files. Editors hold a local copy of the master
2133 repository together with any changes they have made locally.
2134 Local changes are held in a local @q{branch}, of which there may
2135 be several, but these instructions assume you are using just one.
2136 The files visible in the local repository always correspond to
2137 those on the currently @q{checked out} local branch.
2139 Files are edited on a local branch, and in that state the changes
2140 are said to be @q{unstaged}. When editing is complete, the
2141 changes are moved to being @q{staged for commit}, and finally the
2142 changes are @q{committed} to the local branch. Once committed,
2143 the changes (called a @q{commit}) are given a unique 40-digit
2144 hexadecimal reference number called the @q{Committish} or @q{SHA1
2145 ID} which identifies the commit to Git. Such committed changes
2146 can be sent to the master repository by @q{pushing} them (if you
2147 have write permission) or by sending them by email to someone who
2148 has, either as a complete file or as a @q{diff} or @q{patch}
2149 (which send just the differences from the master repository).
2151 @subsection Installing git
2154 @uref{http://code.google.com/p/msysgit/downloads/list} (note, not
2155 msysGit, which is for Git developers and not PortableGit, which is
2156 not a full git installation) and install it.
2158 Note that most users will not need to install SSH. That is not
2159 required until you have been granted direct push permissions to
2160 the master git repository.
2162 Start Git by clicking on the desktop icon. This will bring up a
2163 command line bash shell. This may be unfamiliar to Windows users.
2164 If so, follow these instructions carefully. Commands are entered
2165 at a $ prompt and are terminated by keying a newline.
2167 @subsection Initialising Git
2169 Decide where you wish to place your local Git repository, creating
2170 the folders in Windows as necessary. Here we call the folder to
2171 contain the repository @code{[path]/Git}, but if you intend using
2172 Git for other projects a directory name like @code{lilypond-git}
2173 might be better. You will need to have space for around
2176 Start the Git bash shell by clicking on the desk-top icon
2177 installed with Git and type
2183 to position the shell at your new Git repository.
2185 Note: if [path] contains folders with names containing spaces use
2197 to initialize your Git repository.
2199 Then type (all on one line; the shell will wrap automatically)
2202 git remote add -ft master origin git://git.sv.gnu.org/lilypond.git
2205 to download the lilypond master files.
2207 @warning{Be patient! Even on a broadband connection this can take
2208 10 minutes or more. Wait for lots of [new tag] messages and the $
2211 We now need to generate a local copy of the downloaded files in a
2212 new local branch. Your local branch needs to have a name. It is
2213 usual to call it @q{master} and we shall do that here.
2218 git checkout -b master origin/master
2221 This creates a second branch called @q{master}. You will see two
2222 warnings (ignore these), and a message advising you that your
2223 local branch @q{master} has been set up to track the remote
2224 branch. You now have two branches, a local branch called
2225 @q{master}, and a tracking branch called @q{origin/master}, which
2226 is a shortened form of @q{remotes/origin/master}.
2228 Return to Windows Explorer and look in your Git repository. You
2229 should see lots of folders. For example, the LilyPond
2230 documentation can be found in [path]/Git/Documentation/.
2232 The Git bash shell is terminated by typing @code{exit} or by
2233 clicking on the usual Windows close-window widget.
2237 Almost all subsequent work will use the Git Graphical User
2238 Interface, which avoids having to type command line commands. To
2239 start Git GUI first start the Git bash shell by clicking on the
2240 desktop icon, and type
2247 The Git GUI will open in a new window. It contains four panels
2248 and 7 pull-down menus. At this stage do not use any of the
2249 commands under Branch, Commit, Merge or Remote. These will be
2252 The top panel on the left contains the names of files which you
2253 are in the process of editing (Unstaged Changes), and the lower
2254 panel on the left contains the names of files you have finished
2255 editing and have staged ready for committing (Staged Changes). At
2256 present, these panels will be empty as you have not yet made any
2257 changes to any file. After a file has been edited and saved the
2258 top panel on the right will display the differences between the
2259 edited file selected in one of the panels on the left and the last
2260 version committed on the current branch.
2262 The panel at bottom right is used to enter a descriptive message
2263 about the change before committing it.
2265 The Git GUI is terminated by entering CNTL-Q while it is the
2266 active window or by clicking on the usual Windows close-window
2269 @subsection Personalising your local git repository
2271 Open the Git GUI, click on
2277 and enter your name and email address in the left-hand (Git
2278 Repository) panel. Leave everything else unchanged and save it.
2280 Note that Windows users must leave the default setting for line
2281 endings unchanged. All files in a git repository must have lines
2282 terminated by just a LF, as this is required for Merge to work,
2283 but Windows files are terminated by CRLF by default. The git
2284 default setting causes the line endings of files in a Windows git
2285 repository to be flipped automatically between LF and CRLF as
2286 required. This enables files to be edited by any Windows editor
2287 without causing problems in the git repository.
2289 @subsection Checking out a branch
2291 At this stage you have two branches in your local repository,
2292 both identical. To see them click on
2298 You should have one local branch called @q{master} and one
2299 tracking branch called @q{origin/master}. The latter is your
2300 local copy of the @q{remotes/origin/master} branch in the master
2301 LilyPond repository. The local @q{master} branch is where you
2302 will make your local changes.
2304 When a particular branch is selected, i.e., checked out, the files
2305 visible in your repository are changed to reflect the state of the
2306 files on that branch.
2308 @subsection Updating files from @q{remote/origin/master}
2310 Before starting the editing of a file, ensure your local
2311 repository contains the latest version of the files in the remote
2312 repository by first clicking
2315 Remote -> Fetch from -> origin
2321 This will place the latest version of every file, including all
2322 the changes made by others, into the @q{origin/master} branch of
2323 the tracking branches in your git repository. You can see these
2324 files by checking out this branch, but you must @emph{never} edit
2325 any files while this branch is checked out. Check out your local
2326 @q{master} branch again.
2328 You then need to merge these fetched files into your local
2329 @q{master} branch by clicking on
2332 Merge -> Local Merge
2336 and if necessary select the local @q{master} branch.
2338 Note that a merge cannot be completed if you have made any local
2339 changes which have not yet been committed.
2341 This merge will update all the files in the @q{master} branch to
2342 reflect the current state of the @q{origin/master} branch. If any
2343 of the changes conflict with changes you have made yourself
2344 recently you will be notified of the conflict (see below).
2346 @subsection Editing files
2348 First ensure your @q{master} branch is checked out, then simply
2349 edit the files in your local Git repository with your favourite
2350 editor and save them back there. If any file contains non-ASCII
2351 characters ensure you save it in UTF-8 format. Git will detect
2352 any changes whenever you restart Git GUI and the file names will
2353 then be listed in the Unstaged Changes panel. Or you can click
2354 the Rescan button to refresh the panel contents at any time. You
2355 may break off and resume editing any time.
2357 The changes you have made may be displayed in diff form in the top
2358 right-hand panel of Git GUI by clicking on the file name shown in
2359 one of the left panels.
2361 When your editing is complete, move the files from being Unstaged
2362 to Staged by clicking the document symbol to the left of each
2363 name. If you change your mind it can be moved back by clicking on
2364 the ticked box to the left of the name.
2366 Finally the changes you have made may be committed to your
2367 @q{master} branch by entering a brief message in the Commit
2368 Message box and clicking the Commit button.
2370 If you wish to amend your changes after a commit has been made,
2371 the original version and the changes you made in that commit may
2372 be recovered by selecting
2375 Commit -> Amend Last Commit
2379 or by checking the Amend Last Commit radio button at bottom right.
2380 This will return the changes to the Staged state, so further
2381 editing made be carried out within that commit. This must only be
2382 done @emph{before} the changes have been Pushed or sent to your
2383 mentor for Pushing - after that it is too late and corrections
2384 have to be made as a separate commit.
2387 @subsection Sending changes to @q{remotes/origin/master}
2389 If you do not have write access to @q{remotes/origin/master} you
2390 will need to send your changes by email to someone who does.
2392 First you need to create a diff or patch file containing your
2393 changes. To create this, the file must first be committed. Then
2394 terminate the Git GUI. In the git bash shell first cd to your Git
2401 if necessary, then produce the patch with
2404 git format-patch origin
2407 This will create a patch file for all the locally committed files
2408 which differ from @q{origin/master}. The patch file can be found
2409 in [path]/Git and will have a name formed from the commit message.
2411 @subsection Resolving merge conflicts
2413 As soon as you have committed a changed file your local
2414 @code{master} branch has diverged from @code{origin/master}, and
2415 will remain diverged until your changes have been committed in
2416 @code{remotes/origin/master} and Fetched back into your
2417 @code{origin/master} branch. Similarly, if a new commit has been
2418 made to @code{remotes/origin/master} by someone else and Fetched,
2419 your local @code{master} branch is divergent. You can detect a
2420 divergent branch by clicking on
2423 Repository -> Visualise all branch history
2426 This opens up a very useful new window called @q{gitk}. Use this
2427 to browse all the commits made by yourself and others.
2429 If the diagram at top left of the resulting window does not show
2430 your @code{master} tag on the same node as the
2431 @code{remotes/origin/master} tag your branch has diverged from
2432 @code{origin/master}. This is quite normal if files you have
2433 modified yourself have not yet been Pushed to
2434 @code{remotes/origin/master} and Fetched, or if files modified and
2435 committed by others have been Fetched since you last Merged
2436 @code{origin/master} into your local @code{master} branch.
2438 If a file being merged from @code{origin/master} differs from one
2439 you have modified in a way that cannot be resolved automatically
2440 by git, Merge will report a Conflict which you must resolve by
2441 editing the file to create the version you wish to keep.
2443 This could happen if the person updating
2444 @code{remotes/origin/master} for you has added some changes of his
2445 own before committing your changes to
2446 @code{remotes/origin/master}, or if someone else has changed the
2447 same file since you last fetched the file from
2448 @code{remotes/origin/master}.
2450 Open the file in your editor and look for sections which are
2453 [to be completed when I next have a merge conflict to be sure I
2454 give the right instructions -td]
2457 @subsection Other actions
2459 The instructions above describe the simplest way of using git on
2460 Windows. Other git facilities which may usefully supplement these
2464 @item Using multiple local branches (Create, Rename, Delete)
2465 @item Resetting branches
2466 @item Cherry-picking commits
2467 @item Pushing commits to @w{remote/origin/master}
2468 @item Using gitk to review history
2471 Once familiarity with using git on Windows has been gained the
2472 standard git manuals can be used to learn about these.
2475 @node Repository directory structure
2476 @section Repository directory structure
2479 @c TODO: integrate the roadmap better
2480 @verbatiminclude ROADMAP
2483 @node Other Git documentation
2484 @section Other Git documentation
2488 Official git man pages:
2489 @uref{http://www.kernel.org/pub/software/scm/git/docs/}
2492 More in-depth tutorials: @uref{http://git-scm.com/documentation}
2495 Book about git: @uref{http://progit.org/,Pro Git}
2498 Github help: @uref{http://help.github.com/}
2499 (very highly recommended by Graham)