git primer
DESCRIPTION
A short primer on git basics like git-add, git-commit, and git-pushTRANSCRIPT
GIT PRIMERAvilay ParekhCTO, Co-Founder of Informion, Inc.January 2014
GOALSLearn about git’s three-tree architecture
Become familiar with terms like repo, staged index, working directory, and HEAD.
Get familiar with basic git commands – git add, git commit, git push
ACKNOWLEDGEMENTSKevin Skoglund’s excellent git tutorial on Lynda.com
Pro Git Book(http://www.amazon.com/Pro-Experts-Voice-Software-Development/dp/1430218339/)
3-TREE ARCHITECTURE
Git has three “versions” of source files, all on your local computer. They are referred to as – repo, staging index, working directory
WHAT ARE 3 TREES? Your project directory structure is a “tree”
Git maintains 3 versions of your project on your local computer – repo, staging index, working directory
There aren’t actually 3 physical directory structures
Conceptual sections that are stored in the .git directory of your project
Git clone copies source from a remote git server like bitbucket or github over to local computer
At this point, all three trees on the local computer look exactly alike
staging working
repo
$ git clone https://path/to/git
github
All changes you make are in your working directory.
staging index
working directory
repo
Change some files in project
Changes are copied onto the staging index tree.
staging index
working directory
repo
$ git add .
Changes are copied to the repo. All three trees are alike again.
Working directory is now clean.
staging index
working directory
repo
$ git commit
Repo is the only tree that maintains a commit history in the form of a linked list like structure
Each commit is identified by a GUID
Each commit points to the one before it, its parent
The last commit is also referenced as HEAD
repo
REPO
fff999 5d6ef1 HEAD
Git push will copy the contents of the local repo to the remote git server
If there are any uncommitted changes they will not be copied over
staging working
repo
$ git push
github