git-basics
Take you through an everyday git workflow
Need help at anytime?
http://git-scm.com/book/
man git
git help
man git-<verb> #eg man git-bisect
First Time Setup
Set your user name and email address. Necessary for commits
git config --global user.name "Rusty Taco"
git config --global user.email rustytaco@yolo.com
Import A New Project
git clone git@github.com:amasare/git-basics.git
Make Changes
Modify existing file "donkey.txt"
Create 3 new files "playArea1.txt", "playArea2.txt", "playArea3.txt"
Stage files
Modify existing file "donkey.txt" again
Notice staged and unstaged state when you run a git status.
git status
git status -s (--short)
git diff (--staged)
git add .
git commit -m "Short message describing what you did. "
Remove newly created file "playArea1.txt" from git (staging and working directory -becomes untracked)
git rm playArea1.txt
######Commit Messages Guide
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
###Branches
Create Branch
git branch 'awesome_branch'
git log --decorate #observe which commits all the branches are pointing to
HEAD - branch git is on at the moment
Switch To New Branch
git checkout 'awesome_branch'
Create commit on new branch and check commits pointed to again
Switch to master, check commits pointed to. Changes are isolated!
git log --decorate --all
Merge Branch
Replay changes in awesome_branch since it diverged from master, record result in a new commit on top of master
git merge master
Random Favourites
git blame
git bisect
git log -Sfind_log_this_word_was_introduced
git stash