Preface

Git is a version control Swiss army knife. A reliable versatile multipurpose revision control tool whose extraordinary flexibility makes it tricky to learn, let alone master. I’m recording what I’ve figured out so far in these pages, because I initially had difficulty understanding the Git user manual.

As Arthur C. Clarke observed, any sufficiently advanced technology is indistinguishable from magic. This is a great way to approach Git: newbies can ignore its inner workings and view Git as a gizmo that can amaze friends and infuriate enemies with its wondrous abilities.

Rather than go into details, we provide rough instructions for particular effects. After repeated use, gradually you will understand how each trick works, and how to tailor the recipes for your needs.

Translations

Other Editions

Thanks!

Kudos to Dustin Sallings, Alberto Bertogli, James Cameron, Douglas Livingstone, Michael Budde, Richard Albury, Tarmigan, Derek Mahar and Frode Aannevik for suggestions and improvements. Thanks to Daniel Baumann for creating and maintaining the Debian package. Thanks also to JunJie, Meng and JiangWei for the Chinese translation, and Rodrigo Toledo for the Spanish translation. [If I’ve left you out, please tell me because I often forget to update this section.]

My gratitute goes to many others for your support and praise. I wish this were a real physical book, so I could quote your generous words on the cover to promote it! In seriousness, I greatly appreciate each message. Reading one always brightens my mood.

Free Git hosting

  • http://repo.or.cz/ hosts free projects. The first Git hosting site. Founded and maintained by one of the earliest Git developers.
  • http://gitorious.org/ is another Git hosting site aimed at open-source projects.
  • http://github.com/ hosts open-source projects for free, and private projects for a fee.

Many thanks to each of these sites for hosting this guide.

License

This guide is released under the GNU General Public License version 3. Naturally, the source is kept in a Git repository, and can be obtained by typing:

$ git clone git://repo.or.cz/gitmagic.git  # Creates "gitmagic" directory.

or from one of the mirrors:

$ git clone git://github.com/blynn/gitmagic.git
$ git clone git://gitorious.org/gitmagic/mainline.git

How to Translate This Guide

Clone the source, then create a directory corresponding to the target language’s IETF tag: see the W3C article on internationalization. For example, English is "en", Japanese is "ja", and Traditional Chinese is "zh-Hant". In the new directory, and translate the txt files from the "en" subdirectory.

For instance, to translate the guide into Klingon, you might type:

$ git clone git://repo.or.cz/gitmagic.git
$ cd gitmagic
$ mkdir tlh  # "tlh" is the IETF language code for Klingon.
$ cd tlh
$ cp ../en/intro.txt .
$ edit intro.txt  # Translate the file.

and so on for each text file. You can review your work incrementally:

$ make LANG=tlh
$ firefox book.html

Commit your changes often, then let me know when they’re ready. GitHub.com has an interface that facilitates this: fork the "gitmagic" project, push your changes, then ask me to merge.

I like to have translations follow the above scheme so my scripts can produce HTML and PDF versions. Also, it conveniently keeps all the translations in the official repository. But please do whatever suits you best: for example, the Chinese translators used Google Docs. I’m happy as long as your work enables more people to access my work.