| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| 3.1.1 Setting up | ||
| 3.1.2 Git for the impatient | ||
| 3.1.3 Other repositories | ||
| 3.1.4 Downloading remote branches |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Note: These instructions assume that you are using the command-line version of Git 1.5 or higher. Windows users should skip to Git on Windows.
| Installing Git | ||
| Initializing a repository | ||
| Configuring Git |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you are using a Unix-based machine, the easiest way to download
and install Git is through a package manager such as rpm
or apt-get – the installation is generally automatic.
The only required package is (usually) called git-core,
although some of the auxiliary git* packages are
also useful (such as gitk).
Alternatively, you can visit the Git website (http://git-scm.com/) for downloadable binaries and tarballs.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Once Git is installed, get a copy of the source code:
git clone git://git.sv.gnu.org/lilypond.git ~/lilypond-git |
The above command will put the it in ‘~/lilypond-git’, where
~ represents your home directory.
This creates (within the ‘$LILYPOND_GIT’ directory) a subdirectory called ‘.git/’, which Git uses to keep track of changes to the repository, among other things. Normally you don’t need to access it, but it’s good to know it’s there.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Note: Throughout the rest of this manual, all command-line input should be entered from the top directory of the Git repository being discussed (eg. ‘$LILYPOND_GIT’). This is referred to as the top source directory.
Before working with the copy of the main LilyPond repository, you
should configure some basic settings with the
git config command. Git allows you to set both
global and repository-specific options.
To configure settings that affect all repositories, use the ‘--global’ command line option. For example, the first two options that you should always set are your name and email, since Git needs these to keep track of commit authors:
git config --global user.name "John Smith" git config --global user.email john@example.com |
To configure Git to use colored output where possible, use:
git config --global color.ui auto |
The text editor that opens when using git commit
can also be changed. If none of your editor-related environment
variables are set ($GIT_EDITOR, $VISUAL, or $EDITOR), the default
editor is usually vi or vim. If you’re not
familiar with either of these, you should probably change the
default to an editor that you know how to use. For example, to
change the default editor to nano, enter:
git config --global core.editor nano |
Finally, and in some ways most importantly, let’s make sure that
we can easily see the state of our working copy, without the need
of typing git status repeatedly. If you’re not using
LilyDev, add the following lines to your ‘~/.bashrc’:
export PS1="\u@\h \w\$(__git_ps1)$ " export GIT_PS1_SHOWDIRTYSTATE=true export GIT_PS1_SHOWUNTRACKEDFILES=true export GIT_PS1_SHOWUPSTREAM=auto
The first line will show the branch we’re on. The other lines will use some symbols next to the branch name to indicate some kind of state. “*” means that there are unstaged changes, “+” indicates staged changes; if there are untracked files, a “%” will appear. Finally, we can also see if our HEAD is behind (“<”) or ahead (“>”) of its upstream, and if they have diverged (“<>”) or they are synced (“=”).
You may need to install the additional bash-completion
package, but it is definitely worth it. After installation
you must log out, and then log back in again to enable it.
Git stores the information entered with
git config --global in the file
‘.gitconfig’, located in your home directory. This file can
also be modified directly, without using
git config. The ‘.gitconfig’ file generated
by the above commands would look like this:
[user]
name = John Smith
email = john@example.com
[color]
ui = auto
[core]
editor = nano
|
Using the git config command without the
‘--global’ option configures repository-specific settings,
which are stored in the file ‘.git/config’. This file is
created when a repository is initialized (using
git init), and by default contains these lines:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
|
However, since different repository-specific options are recommended for different development tasks, it is best to avoid setting any now. Specific recommendations will be mentioned later in this manual.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Advanced note: The intent of this subsection is to get you working on lilypond as
soon as possible. If you want to learn about git, go read
Other Git documentation.
Also, these instructions are designed to eliminate the most common
problems we have found in using git. If you already know Git and
have a different way of working, great! Feel free to ignore the
advice in this subsection.
Since our review process delays patches by 60-120 hours, and you want to be able to work on other stuff while your previous work is getting reviewed, you’re going to use branches.
You can think of a branch as being a separate copy of the source code. But don’t worry about it.
Let’s pretend you want to add a section to the Contributor’s Guide about using branches.
Start by updating the repository, then making a new branch. Call
the branch anything you want as long as the name starts with
dev/. Branch names that don’t begin with dev/ are
reserved for special things in lilypond.
git checkout master git pull -r origin master git branch dev/cg |
Nothing has happened to the files yet. Let’s change into the new branch. You can think of this as “loading a file”, although in this case it’s really “loading a directory and subdirectories full of files”.
git checkout dev/cg |
Your prompt now shows you that you’re on the other branch:
gperciva@LilyDev:~/lilypond-git (dev/cg)$ |
To be able to manage multiple lilypond issues at once, you’ll need to switch branches. You should have each lilypond issue on a separate branch. Switching branches is easy:
git checkout master git checkout origin/release/unstable git checkout dev/cg |
Branches that begin with origin/ are part of the remote repository,
rather than your local repository, so when you check them out you get a
temporary local branch. You should never make changes directly on a
branch beginning with origin/. You get changes into the remote
repository by making them in local branches, and then Merging to master.
Edit files, then commit them.
git commit -a |
Remember how I said that switching to a branch was like “loading a directory”? Well, you’ve just “saved a directory”, so that you can “load” it later.
Advanced note: If you have used cvs or svn, you may
be very confused: those programs use “commit” to mean
“upload my changes to the shared source repository”.
Unfortunately, just to be different, git commit
means “save my changes to the files”.
When you create a new file, you need to add it to git, then commit it:
git add input/regression/avoid-crash-on-condition.ly git commit -a |
Edit more files. Commit them again. Edit yet more files, commit
them again. Go eat dinner. Switch to master so you can
play with the latest changes from other developers. Switch back
to your branch and edit some more. Commit those changes.
At this stage, don’t worry about how many commits you have.
Branches are nerve-wracking until you get used to them. You can save your hard work as individual ‘.patch’ files. Be sure to commit your changes first.
git commit -a git format-patch master |
I personally have between 4 and 20 of those files saved in a special folder at any point in time. Git experts might laugh as that behavior, but I feel a lot better knowing that I’ve got those backups.
After committing, you can update your branch with the latest master:
git commit -a git checkout master git pull -r origin master git checkout dev/cg git rebase master |
Due to the speed of lilypond development, sometimes
master has changed so much that your branch can no
longer be applied to it. In that happens, you will have a merge
conflict. Stop for a moment to either cry or have a stiff drink,
then proceed to Merge conflicts.
Finally, you’re finished your changes. Time to upload for review. Make sure that you’re on your branch, then upload:
git checkout dev/cg git push ... |
Afterwards create a merge request to indicate the branch is ready for review.
While you’re waiting for a countdown and reviews, go back to
master, make a dev/doc-beams branch, and start adding doc
suggestions from issue 12345 from the tracker. Or make a
dev/page-breaks and fix bug in page breaking. Or whatever.
Don’t worry, your dev/cg is safe.
Does the history of your branch look good?
gitk |
If you have a lot of commits on your branch, you might want to combine some of them. Alternately, you may like your commits, but want to edit the commit messages.
git rebase -i master |
Follow instructions on the screen.
Note: This step gives you the power to completely lose your
work. Make a backup of your commits by saving them to
‘.patch’ files before playing with this. If you do lose
your work, don’t despair. You can get it back by using git reflog.
The use of git reflog is not covered here.
Note: If any of the commits on your branch represents partial
work that will not pass make && make doc, you must
squash these commits into a working commit. Otherwise, your push
will break automatic testing and will not be able to be merged to
master. In general, you will be safer to have one commit
per push.
When you’ve got the coveted Patch::push status, time to
merge your changes as described in Merging to master.
After the merge request has passed testing and was merged to
master, you can update and then try removing your branch:
git checkout master git pull -r origin master git branch -d dev/cg |
The last command will fail if the commit hashes of dev/cg
are not present in origin/master. This can be because
you used GitLab to rebase your branch, which modifies the commit
data and changes the hash. If you are sure that the branch is not
needed anymore, replace the -d on the final line with a
-D instead.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
We have a few other code repositories.
| lilypond-extra | ||
| Grand Unified Builder (GUB) | ||
| LilyPad | ||
| yet more repositories |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There is a separate repository for general administrative scripts,
as well as pictures and media files for the website. People
interested in working on the website should download this
repository, and set their $LILYPOND_WEB_MEDIA_GIT
environment variable to point to that repository.
https://github.com/gperciva/lilypond-extra |
To configure an environment variable in bash (the default for most GNU/Linux distributions),
export LILYPOND_WEB_MEDIA_GIT=$HOME/dir/of/lilypond-extra/ |
Be aware that lilypond-extra is the definitive source for some binary
files - in particular PDF versions of papers concerning LilyPond. To add
further PDFs of this sort, all that is necessary is to add the PDF to
lilypond-extra and then add a reference to it in the documentation. The
file will then be copied to the website when make website is run.
However, pictures that are also used in the documentation build are mastered in
the main git repository. If any of these is changed, it should be updated in
git, and then the updates copied to lilypond-extra.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Another item of interest might be the Grand Unified Builder, our cross-platform building tool. Since it is used by other projects as well, it is not stored in our gub repository. For more info, see https://lilypond.org/gub.
The location for the repository is:
http://github.com/gperciva/gub |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Our binary releases on MacOS X and Windows contain a lightweight text editor.
To make any modifications the Windows editor, you will need to do the following:
https://github.com/gperciva/lilypad
MinGW provides both a Git installation and a gcc
compiler. This can be obtained from http://www.mingw.org/
git push https://UserName@github.com/gperciva/lilypad.git |
You will need to have push access to the git repository for this to be successful.
https://lilypond.org/downloads/gub-sources/lilypad/.
You will need to have SSH access to lilypond.org. If you do not, contact
the Release Manager via the lilypond-devel mailing list.
source = line to point to
the new source.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are a few other repositories floating around, which will hopefully be documented in the near future.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Note: contains obsolete + misleading info
| Organization of remote branches | ||
| LilyPond repository sources | ||
| Downloading individual branches | ||
| Downloading all remote branches | ||
| Other branches |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The main LilyPond repository is organized into branches to facilitate development. These are often called remote branches to distinguish them from local branches you might create yourself (see Using local branches).
The master branch contains all the source files used to
build LilyPond, which includes the program itself (both stable and
development releases), the documentation (and its translations),
and the website. Generally, the master branch is expected
to compile successfully.
The translation branch is a side branch that
allows translators to work without needing to worry about
compilation problems. Periodically, the Translation Meister
(after verifying that it doesn’t break compilation), will
merge this branch into master to incorporate
recent translations. Similarly, the master branch is
usually merged into the translation branch after
significant changes to the English documentation. See
Translating the documentation for details.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The recommended source for downloading a copy of the main repository is:
git://git.sv.gnu.org/lilypond.git |
However, if your internet router filters out connections using the GIT protocol, or if you experience difficulty connecting via GIT, you can try these other sources:
ssh://git.sv.gnu.org/srv/git/lilypond.git http://git.sv.gnu.org/r/lilypond.git |
The SSH protocol can only be used if your system is properly set up to use it. Also, the HTTP protocol is slowest, so it should only be used as a last resort.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Note: obsolete, should be deleted!
Once you have initialized an empty Git repository on your system (see Initializing a repository), you can download a remote branch into it. Make sure you know which branch you want to start with.
To download the master branch, enter the following:
git remote add -ft master -m master \ origin git://git.sv.gnu.org/lilypond.git/ |
To download the translation branch, enter:
git remote add -ft translation -m \ translation origin git://git.sv.gnu.org/lilypond.git/ |
The git remote add process could take up to
ten minutes, depending on the speed of your connection. The
output will be something like this:
Updating origin remote: Counting objects: 235967, done. remote: Compressing objects: 100% (42721/42721), done. remote: Total 235967 (delta 195098), reused 233311 (delta 192772) Receiving objects: 100% (235967/235967), 68.37 MiB | 479 KiB/s, done. Resolving deltas: 100% (195098/195098), done. From git://git.sv.gnu.org/lilypond * [new branch] master -> origin/master From git://git.sv.gnu.org/lilypond * [new tag] flower/1.0.1 -> flower/1.0.1 * [new tag] flower/1.0.10 -> flower/1.0.10 ⋮ * [new tag] release/2.9.6 -> release/2.9.6 * [new tag] release/2.9.7 -> release/2.9.7 |
When git remote add is finished, the remote
branch should be downloaded into your repository—though not yet
in a form that you can use. In order to browse the source code
files, you need to create and checkout your own
local branch. In this case, however, it is easier to have Git
create the branch automatically by using the checkout
command on a non-existent branch. Enter the following:
git checkout -b branch origin/branch |
where branch is the name of your tracking branch,
either master or translation.
Git will issue some warnings; this is normal:
warning: You appear to be on a branch yet to be born. warning: Forcing checkout of origin/master. Branch master set up to track remote branch master from origin. Already on 'master' |
By now the source files should be accessible—you should be able to edit any files in the ‘$LILYPOND_GIT’ directory using a text editor of your choice. But don’t start just yet! Before editing any source files, learn how to keep your changes organized and prevent problems later—read Basic Git procedures.
The git remote add command should add some
lines to your local repository’s ‘.git/config’ file:
[remote "origin"]
url = git://git.sv.gnu.org/lilypond.git/
fetch = +refs/heads/master:refs/remotes/origin/master
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
To download all remote branches at once, you can clone
the entire repository:
git clone git://git.sv.gnu.org/lilypond.git |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Most contributors will never need to touch the other branches. If you wish to do so, you will need more familiarity with Git; please see Other Git documentation.
dev/XYZ:
These branches are for individual developers. They store code
which is not yet stable enough to be added to the master
branch.
stable/XYZ:
The branches are kept for archival reasons.
archive/XYZ:
The branches are kept for archival reasons.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by gub on July 13, 2020 using texi2html 1.82.