Getting Started
- Setup .gitattributes correctly
- Setup .gitignore correctly
- Setup ~/.gitconfig correctly
- config [--global] --unset user.email
- config [--global] --edit
- config [--global] user.email Phil@foo.com
- config --list
Do this first!!!
- verb --help
- man git-verb
Help
- init
- clone url [mydir]
Repository Creation and Cloning
- 1a. init --bare newrepo.git
- 1b. clone --bare url
- 2a. remote add origin user@server:path/to/newrepo.git
- 2b. remote set-url origin user@server:path/to/newrepo.git
- 2c. clone user@server:path/to/newrepo.git
- 3. push --all origin
Using a Bare Repo as a Central Repo
- gui
- gitk [--all] [file]
- gui blame filespec
- mergetool
- difftool
Graphical Tools
- Scott Chacon's site
- Andrew Peterson's cheat sheet
- How to escape a git mess
- Stack Overflow git intro
- Main git doc page at kernel.org.
- Git Flow
Other Docs
Daily Work
- add pathspec
- add -A pathspec
- add -i pathspec
- mv oldfile newfile
Staging
- reset [sha] pathspec
- checkout [sha] -- pathspec
- rm --cached pathspec
- rm pathspec
- rm 'foo/*.log'
Un-Staging
- commit [-m "message"]
- commit -a
- commit --amend [-m "message"]
- commit --amend --no-edit
- commit pathspecs
Committing
- show HEAD~4:File > OldFile
- reset --soft sha
- reset --soft HEAD^
- reset [--mixed] sha
- reset --hard sha
- reset --hard HEAD^
- reset --hard HEAD
- reset --hard ORIG_HEAD
Undoing
- revert [shas]
- revert --continue
- revert --quit
- revert --abort
Reverting
- clean [-f] [-d]
- clean -i
- clean -n
- clean -x
- filter-branch
Cleaning
Branching
- branch -r | -a
- branch -v | -vv
- branch -merged
- branch -no-merged
- branch newbrname [sha]
- branch --track newbr short/brname
- branch -d brname
- show-branch [-r] [-a] [brnames]
- push -u shortname brname
Managing
- checkout [-f | -m] brname
- checkout -b newbrname [sha]
- checkout --track shortname/brname
- checkout -b newname shortname/brname
Switching To
- merge [--no-commit] sourcebr
- mergetool
- manual resolution
- merge --abort
- rebase [--onto newbase] brname
- rebase -i brname
- rebase --continue
- rebase --abort
- checkout --ours | --theirs
- cherry-pick sha
- merge-base sha1 sha2...
Merging and Rebasing
- 1. checkout master
- 2. pull
- 3. checkout -b f-myfeature
- 4. work on your feature
- 5. fetch origin (when done)
- 6. diff origin/master (Optional)
- 7. rebase -i origin/master
- 8. checkout master
- 9. pull
- 10. merge [--no-ff] f-myfeature
- 11. branch -d f-myfeature
- 12. push
Branch/Rebase/Fast-Forward Workflow
Git Flow
- The master branch
- The develop branch
- Feature branches
- Release branches
- Hotfix branches
Introduction
- 1. checkout develop; git pull
- 2. checkout -b f-myfeature
- 3. work on your feature
- 4. rebase -i develop (Optional)
- 5. checkout develop; git pull
- 6. merge --no-ff f-myfeature
- 7. branch -d f-myfeature
- 8. push origin develop
Working on a feature
- 1. checkout develop; git pull
- 2. checkout -b release-1.2
- 3. ./bump-version.sh 1.2
- 4. commit -am 'Bump version to 1.2'
- 5. time passes ... apply hotfixes ...
- 6. checkout master; git pull
- 7. merge --no-ff release-1.2
- 8. tag -a 1.2
- 9. checkout develop; git pull
- 10. merge --no-ff release-1.2
- 11. branch -d release-1.2
- 12. push
Creating a release
- 1a. checkout -b hotfix-1.2.1 master
- 1b. checkout -b hotfix-0.9.1 0.9
- 2. ./bump-version.sh 1.2.1
- 3. commit -am 'Bumped version to 1.2.1'
- 4. work on the hotfix
- 5. commit -am 'Fixed production problem.'
- 6. checkout master; git pull
- 7. merge --no-ff hotfix-1.2.1
- 8. tag -a 1.2.1
- 9. checkout develop; git pull
- 10. merge --no-ff hotfix-1.2.1
- 11. branch -d hotfix-1.2.1
Making hotfixes
Remotes
- remote [-v]
- remote add shortname url
- remote set-url shortname url
- remote rm shortname
- remote rename oldname newname
- remote show shortname
Setup
- fetch [shortname]
- fetch --tags [shortname]
- pull [--rebase] [shortname]
Fetching and Pulling
- fetch shortname
- diff master shortname/master
- merge shortname/master
- rebase [-i] shortname/master
Manual Fetch and Merge
- push
- push -u shortname brname
- push --all -u shortname
- push shortname brname:brname2
- push shortname :brname
- push shortname v1.5
- push shortname --tags
Pushing
- Introduction
- subtree add ...
- subtree pull ...
- subtree push ...
- Terminating the link
Subtrees (Sharing code)
Reviewing
- diff [-- path] [--stat]
- diff --cached [sha] [-- path]
- diff sha [-- path]
- diff sha1 sha2 [-- path]
- diff HEAD~ -- filespec
- diff sha1\...sha2 [-- path]
- diff --name-status --oneline sha1 sha2
- diff :1:filespec :3:filespec
- difftool
Comparing
- status [--short] [--ignored]
- gitk [--all] [file]
- log [options] revisionrange
- log [options] brname
- log [options] -- pathspec
- log [-N]
- log --[after|before]=datespec
- log -p
- log --stat | --shortstat
- log --author=somebody
- log --committer=somebody
- log --grep=pattern
- log -S'string'
- log -G'pattern'
- log -L start,end:file
- log -i
- log --all-match
- log origin/master..HEAD
- log --pretty=...
- blame filespec
- gui blame filespec
Status and History
- log sha
- log ^sha
- log sha1..sha2
- log master..f-myfeature
- log f-myfeature..master
- log origin/master..HEAD
- log ^exc1 ^exc2 inc1 inc2
Commit Ranges
Misc 1
- revparse ref
- reflog [log options]
- show [options] [things]
- show sha1
- show ref
- show ref:pathspec
- show :pathspec
- show @
- show ref@{date}
- show ref@{N}
- show rev~N
- show rev^N
- show HEAD~4:File > OldFile
Showing Objects
- stash list
- stash save [--untracked | --all] [msg]
- stash show [stash]
- stash pop [stash]
- stash apply [stash]
- stash branch brname [stash]
- stash drop [stash]
- stash clear
Stashing
- tags vs branches
- tag
- tag -l v1.4*
- show v1.4
- tag -a v1.4 -m "message"
- tag -a v1.4 sha
- push shortname v1.5
- push origin --tags
- tag -f v1.4 sha
- tag -d v1.4
Tagging
- bisect start
- bisect run my_script args
Bisection
- ls-files -s | -u
- cat-file -p sha