Git is best understood as a developer tool—a distributed version control system—not a programming language, a concept, or a set of best practices. Its job is to record how files change over time. A simple way to picture version control is taking a child's photograph once a year: each snapshot preserves a state that can be compared with earlier and later ones. In a distributed system, there is no strict server/client division; a copy can carry a complete history, which makes the system secure and self-contained.

Why version control matters

Version control gives freedom: freedom to experiment, freedom to branch, freedom to share. That matches the spirit of open source and free software. Branches make it possible to try ideas without disturbing the main line of work, and sharing lets other people inspect, reuse, and improve what has been built.

Where Git came from

Git grew out of Linux kernel development. Linus Torvalds, the creator of Linux, built it to manage kernel code. He examined several existing source control systems and concluded that none was fast enough, so he wrote his own.

What makes Git distinctive

Git is small and fast. It is genuinely distributed. Its staging area is a thoughtful design choice that lets you decide what should go into the next commit. It also works well with GitHub. The site WhyGitIsBetterThanX.com compares Git with other tools.

A discussion of Git best practices

GitHub and the culture of open source

GitHub lives at http://github.com/. Open-source culture is not simply about software costing nothing. It distinguishes free software, such as the Linux kernel, from open source, such as Firefox, and from products that are merely gratis. The free software and open source movements use the internet as their stage: mailing lists, wikis, forums, and communities. Individuals and companies both participate heavily. Collaboration is the strength of these communities, and it has produced many strong resources and products. WebKit is a typical example.

Language rankings in GitHub repositories

How to take part in open source

Find good communities and projects that interest you. Watch and learn: understand the context and read the code. Start small by fixing a bug or an issue. Make patches. Get comfortable with version control techniques. Follow coding standards and project conventions. Then go further: join project discussions and management, become a regular member, create or fork your own branch or version, and plan for the long term. The core is sharing and contributing, not just taking.

Using Git in practice

At the simplest level, Git and GitHub can be used to find and download a program. You can search for a project or a developer, then follow projects, follow developers, and download open-source code. Prospecting on GitHub means searching keywords, following developers, watching projects, viewing or previewing files online, clicking the download button, and unzipping the archive. That is a long way from really knowing Git, of course.

Searching projects and developers on GitHub

Following projects and downloading code on GitHub

Relationship between local and remote Git repositories

Installing and configuring Git

Start with the command line. A few common commands are enough to move around:

  • whoami — the 'hello world' of the command line
  • ls(dir)/cd/mkdir/rmdir — list, enter, create, or remove directories
  • cp(copy)/mv(move)/rm(del) — copy, move, or delete files
  • <cmd-name> -x --xxxx (/xx) — run a command
  • <cmd-name> -h --help (/?) — show help information

Windows equivalents are shown in parentheses.

Git is available for the main platforms:

  • Mac: http://code.google.com/p/git-osx-installer/
  • Linux: sudo apt-get git ...
  • Windows: msysgit or cygwin

For cygwin, select the following modules:

devel → git
editors → vim/nano

Then run cygwin.bat and use Git from the command line. If cygwin does not work normally, run:

$ cygwin/bin/ash.exe
$ /bin/rebaseall

Selecting Git modules during Cygwin installation

Cygwin directory structure

Cygwin initialization

Configure Git with your identity:

git config --global user.name "..."
git config --global user.email ...

For a GitHub account, provide an SSH key as described in GitHub's guide: http://github.com/guides/providing-your-ssh-key