"The information manager from hell" -- Linus Torvalds

So what is Git exactly?

Linus Torvalds said it best...

GIT - the stupid content tracker

"git" can mean anything, depending on your mood.

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronounciation of "get" may or may not be relevant.

  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.

  • "global information tracker": you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.

  • "goddamn idiotic truckload of sh*t": when it breaks

This is a stupid (but extremely fast) directory content manager. It doesn't do a whole lot, but what it _does_ do is track directory contents efficiently.

Linus' original README.

What's different about Git?

Great question partner

Old version control systems saw files as a series of deltas, you would save all the files under version 1, then look at the files as a series of changes from the baseline.

Git sees commits as a series of snapshots. Pointers are updated if the files haven't changed.

The Three States

Working Tree / Staging Area / .git Directory

Git has three main states files can reside in:

  • Modified: Modified means that you have changed the file but have not committed it to your database yet.

  • Staged: Staged means that you have marked a modified file in its current version to go into your next commit snapshot.

  • Committed: Committed means that the data is safely stored in your local database.

what is git?
Git has three main types of objects that are stored:

  • Blobs: which are usually files that are compressed and hashed.

  • Trees: which are structures that point to the files, analogous to directories.

  • Commits which store information about the hash values, who saved them, when and why they were saved.

git objects
Everything in git is checksummed before it is stored, and then is referred to by that checksum. Git uses a SHA-1 hash to perform the checksumming --> 40 Character string composed of hex chars. And calculated based on contents of file or directory structure. Here's an example of a SHA-1 hash. 24b9da6552252987aa493b52f8696cd6d3b00373

Starting a Repository on a Server

The Watering Hole

A git remote repository is generally a bare repository. This means a repository that has no working directory, no unpacked files on disk. It simply has all of the git repository information, along with all the blobs.

git init git init --bare --shared git clone domain/directory.git git pull git push
git on the server

Show me some Commands!

Hold your horses now

git config git config --list --show-origin git config --global "John Doe" git config --global git config --global core.editor vim git config --global "checkout"

Diffs and Commits
git diff (HEAD, HEAD^, HEAD~3) git diff --staged git commit --amend git reset --hard `commit` git reset --soft `commit`

git branch somebranch (only makes a new branch) git checkout -b somebranch (makes a branch and switches to it) git branch --merged (shows branches that are merged into current branch)

git remote -v git remote show `remote` (i.e origin) git push --set-upstream origin master (or feature branch) git checkout --track `remote`/`branch` (i.e origin/somebranch)

Last but not least... If you forget all of this information, or you find yourself in a pickle, there's a great website to reference: Oh Shit, Git!?! And Finally, here's a great visual cheat sheet for all the commands: Git Cheatsheet
That's all for me, now I reckon ya'll better git outta here and start version controlling your software. Yeeeeeee haw.