Development/Git For LibreOffice Developers

Git is a (DVCS). It is a very powerful yet simple system, but if you are unfamiliar with DVCS, it can be confusing. Thankfully there are great resources on the web to learn about Git. If you are not familiar with it, you should visit: The rest of this article will assume a basic working knowledge of Git.
 * https://learngitbranching.js.org/ for excellent visualized learning-by-doing.
 * https://git-scm.com/book/ Pro Git book by Scott Chacon and Ben Straub
 * Git is a Directed Acyclic Graph (archived by ) -- if you know what a DAG is this is the quickest theory explaination
 * https://www.youtube.com/watch?v=1ffBJ4sVUb4 for a easy and visual explanation.
 * https://who-t.blogspot.com/2009/12/on-commit-messages.html How to write good commit messages.
 * https://github.com/k88hudson/git-flight-rules A guide for gitstronauts about what to do when things go wrong.

Most of LibreOffice source code is in the  git repository, but a few modules are in separate repositories, ,   and. In most cases you probably won’t have to modify these repositories.

Managing Git branches

 * See: Development/Branches

A tip for displaying branch in your terminal prompt (Linux)
To display the branch you are working on, like

you can modify your PS1 prompt variable by adding the following to your $HOME/.bashrc :

Hack and commit on a stable branch
Stable branches are created from  or another stable branch to stabilize the code base for the release and further maintenance updates. There are some rules during the beta phase:


 * Allowed are any changes in translations
 * Allowed are any bug fixes
 * Allowed are late features that are approved by the Engineering Steering Committee

There are more strict rules during the release candidate phase:


 * Allowed are safe fixes that are reviewed by another person, see below
 * Allowed are changes in translations; it is recommended to ask for review on the native l10n mailing list

Please, do not commit the fixes directly during the RC phase. Instead, please send your patch to gerrit or ask another developer for review on the [mailto:libreoffice@lists.freedesktop.org libreoffice@lists.freedesktop.org] mailing list, personal mail, on IRC or via the related bug entry. The fix should be committed by the reviewer using:

What to do when does not want to operate
It is usually due to local changes in your repository. You can either get rid of them, using:

or stash them temporarily, and get them back again after the git pull -r:

Reset your modified repo to a “vanilla” repository
will discard all your local changes (whether committed or not) and reset the current branch that you are on to the one on the remote repository.

Delete untracked or ignored files
To clean out junk like temp files and old development logs and create a pristine working directory

Reorder, squash and in general tweak your local history:
is a powerful tool that allows you to “rewrite” your local history.

Let’s say you are on  and the last 3 commits are A,B,C=HEAD but C is actually a correction of the commit A that you missed before committing B. So what you would want to do is to merge A and C together and end-up with A',B as history.

To do that you can

This is just in case something goes very wrong and you want to just undo everything and go back to the initial sate

This should bring, in your favorite editor (as set by the variable ) a list of the last 3 commits, from the oldest to the newest (the reverse order than normally in git log), so C is the last of the list:

pick 726fe9c enable localization of extension descriptions in mysqlc pick 9ab6ecf fix en-US only build pick a18bfb0 Revert "enable localization of extension descriptions in sdext" # # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # #
 * 1) Rebase 1846533..a18bfb0 onto 1846533
 * 1) Commands:
 * 1)  x, exec = Run a shell command , and stop if it fails
 * 1) If you remove a line here THAT COMMIT WILL BE LOST.
 * 2) However, if you remove everything, the rebase will be aborted.

Edit it, moving commit C one-up and changing its action to :

pick 726fe9c enable localization of extension descriptions in mysqlc squash a18bfb0 Revert "enable localization of extension descriptions in sdext" pick 9ab6ecf fix en-US only build

Then save and exit the editor.

Now you can edit the commit message of the merged commit:

# This is a combination of 2 commits. # The first commit's message is: enable localization of extension descriptions in mysqlc Change-Id: I7141eea0fe7f72408da0d2a5ebe4a5e2891b6b7d # This is the 2nd commit message: Revert "enable localization of extension descriptions in sdext" Change-Id: Iff01d31792a13a14ea720c477417217af0c01642

Once you have combined the 2 commit messages, save and exit again.

If everything went nicely you should be on  with your HEAD on B and A+C fused into one commit A', just before B. If things went wrong and you are lost:

If things are not reverted to the way they should (compounded wrongness :-) you can

to pretend nothing ever happened :-)

Getting and using commit access
In order to get commit access you need to be "sponsored". Once you've submitted patches and got yourself recognised this won't be a problem, but it's best to wait until you're asked or ask for someone to sponsor you.