Git For Ages 4 And Up by Michael Schwern
It is not you, is really is complicated
It is easier to understand git from inside out, cause the interface is so far…
Getting started – init and clone
- Entire repo in .git directory after “git init”
Getting stuff done add and commit
- add writes to the repo
- commit creates a commit object and puts labels on it
- take a new copy this file.
- Add creates a new node, commit attaches a commit-object to it and moves the head and master
Branching
- git branch feature – added feature label to current node
- git checkout feature – next commit will move feature label
- git commit – moves the feature label and the head
- head always points to what you have checked out
Commits
- Every one is unique and has unique id
- They never change
- content, author, date
Staging area / Index / Cache
- Place to build up stuff before a commit
- eg what is in “add”
Workflow
- Isolate -> work <-> update -> share
- git checkout master – move back to master branch, can’t see stuff in branch
- get merge feature – merge in the branch “feature”
- git log –graph –decorate all
- reset – “arbitary move labels around command”
- Merge master back into feature
- git checkout feature
- git merge master
- Unlike cvs “commit does not meet share”
Working with others
- git clone remote work – clones a remote into work folder
- Normally “remote” will be the URL of the remote repo
- origin/master – label to commit where git thinks remote currently is.
- pull == fetch + merge
- git checkout -b bugfix – checkout and branch
- git push origin bugfix – push to the branch “bugfix” on the remote “origin”
- git push -u origin bufix – the -u sets the default branch to push to on the remote “origin” for next time
Tags
- git tag v1.0 b08234
- Add any old random tag to a commit, defaults to current commit you are on
- cannot move tags except with force
- can branch from tags
Rebase
- git rebase -i – interactive mode
- squash
- creates a new commit ( hanging off parent of commit your are rebasing ) and move branch to it, leaves previous branch hanging detached
- Don’t rebase after you have pushed