I don't even know Git !
Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.
Git is used for version control of files, much like tools such as Mercurial, Bazaar, Subversion, CVS, Perforce, and Team Foundation Server.
- A quick and pretty reminder of most basic commands: http://rogerdudler.github.com/git-guide/
- A free book: http://progit.org/book/ (support the authors, buy a copy!)
- The Git homepage: http://git-scm.com/
- The Git reference http://gitref.org/
- The Git community book: http://book.git-scm.com/
- If you're still up for more reading, this should quench your thirst: http://schacon.github.com/git/user-manual.html
- A StackOverflow guide/meta thread: http://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide
- An interactive cheat sheet: http://www.ndpsoftware.com/git-cheatsheet.html
- DZone refcard: http://refcardz.dzone.com/refcardz/getting-started-git
- Lars Vogel's Git tutorial: http://www.vogella.com/articles/Git/article.html
- 'Git from the bottom up' (extensive PDF): http://ftp.newartisans.com/pub/git.from.bottom.up.pdf
- Google !
(please add your own and/or leave comments as to which of these guides/docs work the best)
Make sure you have at least Git 1.7.
On OSX: If you have an older version, please upgrade. (Use homebrew, macports, or simply the official installer).
On Windows: check this out:http://blog.tfnico.com/2012/04/my-git-setup-on-windows.html
On Linux: you're a big boy, aren't you ?
(seriously though, links/instructions welcome. Please update this page)
Configure name and username
Type this, once and for all:
Display the current branch name in your terminal
I could not work without this anymore. Add the following to your
You won't want to use Git without this anymore. If you used the OSX installer, add this to your
If you installed Git with MacPorts, then add this line to your
Git at Magnolia
Repositories hosted at
git.magnolia-cms.com are accessible via a number of URLs:
- read-only over HTTP:
http://git.magnolia-cms.com/<repo>.git. You can use this to clone, fetch and pull a repository, but you won't be able to push. This is only available for our open-source projects.
- authenticated HTTPS:
https://git.magnolia-cms.com/<repo>.git. Allows you to push - if you're allowed to for the given repository, anyway. Use your Magnolia credentials. (see #HTTP credentials below)
firstname.lastname@example.org:<repo>.git. Allows you to push - if you're allowed to for the given repository, anyway. Uses SSH keys, so make sure we have it. (see #SSH Keys below)
- Lastly, you can also browse them on Gitweb at
<repo> is the name or path of the repository you want to clone, e.g.
git clone email@example.com:modules/dms.
To know what repositories are available, or to validate your configuration, you can simply try to connect to the server:
This should get you a message such as
This means you can read/write the
modules/foobar repository, and have read-only access to the
modules/bazqux repository. Additionally, you have full access to the
testing repository, like everyone else.
If on the other hand, if you get this message:
... that means your public key isn't configured properly (either on your machine, or on the server). To only way to fix this at the moment is to contact me directly; send me your public key.
Have a look at Git repositories structure for details on how repositories are structured.
Hey, this repository moved !?
Have a look at Git repositories structure for details on how repositories are structured, and where projects migrated from SVN have been moved to.
Hey, now I have been granted write access to this repository, what do I do ?
In both cases, what you need to do is change the URL of the "remote" you're using for that repository. If you're familiar with Git, you'll know how to do this, and you might even feel comfortable with using multiple remotes. If not, this is a simply way to change the default remote (usually named
So whether a repository has been moved (perhaps to a new subfolder on the same server, perhaps to another server), renamed, or you now need to use HTTPS or SSH instead of HTTP, you know what to do.
Tags, branches, detached mode
Since many of our Git repositories have been migrated from our Subversion repository (see below), there are a lot of projects where tags and branches have the same name (typically
magnolia-module-xyz-1.2 is both a branch and a tag). If you attempt to
git checkout magnolia-module-xyz-1.2, you'll end up in detached mode, AND your local copy will reflect the contents of the tag. If you did want the tag, all is fine and dandy. If you wanted the branch, you need to do two things:
- provide git with the full name of the reference for this branch.
origin/magnolia-module-xyz-1.2usually does the trick, although the real full name is likely going to be
create the branch locally and track it (if you checkout a branch, by default it's "remote", which is why you'll still be in detached mode if you just do
git checkout origin/magnolia-module-xyz-1.2, so you'll need to instruct Git to "create" that branch locally and map it to the remote branch)
The long version of this is
.. but a shortcut that should work just as well for more situation is:
If you have an account at Magnolia (as a community/forge member, a customer, or even an employee), you should be able to clone repositories from our Git repository. If you don't, the open source repositories should still be visible on GitWeb; you should be able to clone them anonymously.
If your credentials don't seem to work like they did with SVN, please get in touch !
To avoid typing your credentials over and over again, you should make sure you have Git 1.7.9+, and do one of the following:
There are other credential storage available depending on your installation; find them with
git help -a | grep credential-. For more details, see http://www.manpagez.com/man/7/gitcredentials/
If you're using the Mac OSX installer, it seems the keychain credentials support isn't included yet - vote for http://code.google.com/p/git-osx-installer/issues/detail?id=82 - in the meantime, you can download and install it manually:
We usually don't maintain accounts using SSH keys, because it's just too cumbersome; if you really want or need to, we can help. But if you can use the HTTP(S) protocol, it's preferred.
GitHub has a fairly decent Getting Started guide at http://help.github.com/set-up-git-redirect, which covers the creation of ssh keys. If you're using Putty on Windows, the Gitolite documentation might also help: http://sitaramc.github.com/gitolite/contrib_putty.html
If you need access to the Git repository over SSH, send your public key along with your username to one of the administrators.
The server and migration of the canonical/remote repositories is described on our SYS wiki.
The migration status is documented on the Git repositories structure page.
To switch your local copy from Subversion to Git, just do a clone, and replace the directories. Since the Subversion repository remains accessible in read-only mode, you can apply any local changes you had with commands along these lines: ( this script is only an example, take it with a pinch of salt and adapt it to your own needs)
Some of our repositories are mirrored on GitHub. See https://github.com/Magnolia/. These are copies (sometimes partial) of our canonical repositories. As such, pushing to GitHub will not work. Well, it will, but your changes will be overriden by the next push to the canonical repository.
If the connection test showed you a line like
C R W user/jdoe/.*, you have the possibility to create your own repositories.
To start a new one, just do
If you already have a local repository, you can push to this new one with
Note that the
origin name is completely arbitrary and up to you. You can use any descriptive name you like.
origin is the default in git, so it's generally good practice to keep this name for the canonical, i.e "origin" repository.
To start a new repository with the https protocol the commands are as follows:
Sharing your user repository
If you create a user repository as above and want to get other people to read or write to it, see http://gitolite.com/gitolite/g2/setperms.html
READERS, which are arbtitrary "roles" that we added in Gitolite for user repos; usernames are LDAP UIDs. (http://gitolite.com/gitolite/g2/user.html#user_set_get_additional_permissions_for_repos_you_created_)
At the moment, Pete Ryland, Philip Mundt and Grégory Joseph have administrative access to the Git server. So contact either of us to create repositories or user accounts.
For details on our setup, see the Git page in Systems & Infrastructure space.
Tips, tricks and other troubleshooting
Please see Git tips and tricks for more tips, tricks and advice !