by Sarah Sharp
WARNING:
I am a unique snowflake
WARNING:
This tutorial may make you lazy
WARNING:
Some Git features are
dangerous!
Git Basics
● See Everyday Git Tutorial:
– http://www.kernel.org/pub/software/scm/git/d
ocs/everyday.html
● My git commands:
– git add - git commit
– git diff - git log - git show
– git push - git pull
– git fetch - git rebase
Setting up a
remote repository
Setting up a
remote repository
● Server needs git installed to use git+ssh
to push to your repo
● Server needs webdev installed to allow
pulls over http
● http://github.com/ will host your repo
● Next directions assume you have your
own server with git installed
Setting up a
remote repository
1. Make local repo, commit stuff, etc.
2. ssh to the server:
GIT_DIR=/path/to/repo git init --shared
3. Next, tell the local repo about the server:
git remote add origin git+ssh://hostname/path/to/repo
4. Push to the server from the local repo:
git push origin master
5. Clean up the local repo so that you can pull from the
remote server:
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
Git Philosophy
Git Philosophy
● Commit early, commit often
● One commit represents one idea or one
change.
– Makes it easy to read patches
– Easy to revert unwanted changes later
● Your working directory, index, and local
repo are your scratch pads.
Frequent Use Infrequent Use
git diff
● Only pays attention to tracked files
● git diff
– differences between workspace and index
● git diff --cached
– differences between index and local repo, i.e.
changes to be commited
● git diff HEAD
– differences between workspace and local
repo
Viewing History
● git log
● git log <commit ID>
– shows history before that commit
– e.g. git log HEAD
● git log -p
– shows log as a series of patches
The Index, the staging area