Hands on git!
setup
- install git (prefereably 2.0.0+)
- define git user
git config --global user.name "My Name"
git config --global user.email "me@mail.org"
- (optional) setup bash completion
- (optional) setup custom prompt
- (optional) signup on GitHub (see student pack)
exercices
notes
Refer to the course material or Pro Git or StackOverflow when in doubt. And use git reflog
when in panic!
Common git commands:
git init
: initialize new local repositorygit clone
: initialize repository from remotegit status
: show current stategit reflog
: show history of commits (even no longer reachable)git add
: stage contentgit rm
: remove file from trackinggit commit
: create new revision based on staging areagit branch
: control branch lifecyclegit checkout
: set local filetree to revision (also used to create new branch with-b
)git reset
: set commit tree to revision (along with filetree when--hard
)git merge
: join 2+ branches togethergit rebase
: rewrite branch historygit cherry-pick
: apply changes from commitgit log
: list commit treegit show
: show commit datagit diff
: compare commitsgit push
: publish branchgit fetch
: update remote namespacegit pull
: update upstream remote and merge/rebase current branch