Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Notes from reading Pro Git
Notes from reading Pro Git:
1.1 Getting Started - About Version Control
A version control system (VCS) tracks different versions of files. RCS is an example of a local VCS.
To collaborate with other developers, you need a centralized VCS, like Subversion. A single server has the authoritative copy of the revision history; clients check out a particular revision. If you lose the server, though, nobody can commit and you potentially lose history.
With a distributed VCS (Git, Mercurial) each client fully mirrors the repository, including all revision history. This reduces your reliance on a single master server, and allows more flexible workflows across multiple collaborators.
1.2 Getting Started - A Short History of Git
The Linux kernel used to use a proprietary DVCS called BitKeeper. Then BitKeeper wanted to start charging them, so Linus went off and wrote his own DVCS. The goals were speed, simplicity, and support for very large projects with thousands of branches.
1.3 Getting Started - Git Basics
Most VCS track a set of files and the changes made to each file over time. Git treats your repository as a filesystem and each commit as a snapshot.
Because your git repo is a mirror of the full repository, most operations are entirely local and quick, since you're not waiting on an answer from a remote centralized server. This also means that you can work offline.
Each commit is checksummed with a SHA-1 hash. If you lose data in transit, Git will know because a checksum won't match.
Nearly every operation adds to the Git database. If you screw something up, there's almost always a way to revert it.
Git files can be committed, modified, or staged.
- Committed files have the most recent version stored in Git's database.
- Modified files have local changes that you have not yet committed.
- Staged files have been marked for inclusion in your next commit.
Files can exist in 3 places:
- Your working directory is a single checkout of one version of the project.
- Your staging area is the list of files that are staged to go into the next commit.
- Your .git directory is the database containing your full revision history.
1.4 Getting Started - The Command Line
This book only covers the Git CLI.
1.5 Getting Started - Installing Git
$ sudo apt-get install git-all
$ sudo yum install git-all
1.6 Getting Started - First-Time Git Setup
Git configuration is defined at three levels:
System - System wide; defined in
/etc/gitconfig; edit with
git config --system
Global - User specific; defined in
~/.gitconfig; edit with
git config --global
Repository - Project specific; defined in
.git/configin current project; edit with
More specific configuration overrides more general configuration.
Set your identity:
$ git config --global user.name "John Doe" $ git config --global user.email email@example.com
Set your editor:
$ git config --global core.editor emacs
See all config:
$ git config --list user.name=John Doe firstname.lastname@example.org color.status=auto color.branch=auto color.interactive=auto color.diff=auto ...
Check a specific config value:
$ git config user.name John Doe
1.7 Getting Started - Getting Help
$ git help <verb> $ git <verb> --help $ man git-<verb>
Or try the
#git channel on irc.freenode.net. Wow, throwback.
2.1 Git Basics - Getting a Git Repository