git primer

11
GIT PRIMER Avilay Parekh CTO, Co-Founder of Informion, Inc. January 2014

Upload: avilay-parekh

Post on 27-Jun-2015

150 views

Category:

Technology


2 download

DESCRIPTION

A short primer on git basics like git-add, git-commit, and git-push

TRANSCRIPT

Page 1: Git primer

GIT PRIMERAvilay ParekhCTO, Co-Founder of Informion, Inc.January 2014

Page 2: Git primer

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

Page 3: Git primer

ACKNOWLEDGEMENTSKevin Skoglund’s excellent git tutorial on Lynda.com

Pro Git Book(http://www.amazon.com/Pro-Experts-Voice-Software-Development/dp/1430218339/)

Page 4: Git primer

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

Page 5: Git primer

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

Page 6: Git primer

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

Page 7: Git primer

All changes you make are in your working directory.

staging index

working directory

repo

Change some files in project

Page 8: Git primer

Changes are copied onto the staging index tree.

staging index

working directory

repo

$ git add .

Page 9: Git primer

Changes are copied to the repo. All three trees are alike again.

Working directory is now clean.

staging index

working directory

repo

$ git commit

Page 10: Git primer

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

Page 11: Git primer

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