Notes from the video: Introduction to Git with Scott Chacon of GitHub
Git is an open source, distributed version control system designed for speed and efficiency
(almost) everything is local wich means everything is fast, every clone is a backup and you can work offline.
No network needed to:
- Performing a diff
- Viewing file history
- Commiting changes
- Merging branches
- Obtaining other revisions of a file
- Switching branches
(almost) never removes data wich means you will never re-write history. Git will move its points to a new commit.
Snapshots, not Patches
git clone
git init
git status / git diff
git add .
git add -p (patch commits)
git commit - m 'initial message'
git log
git chekcout master (change branch to master)
git branch
git checkout -b email master (checkout master, create email branch and checkout email branch)
git commit -a 'message' (stage and commit)
git checkout master
git merge email (merge email to master)
git branch -D branch (delete branch)If you are working in a branch, keep merging master to the featured branch every single day.
git merge --ff-only email ?git config --global user.name "Your Name"
git config --global user.email "youremail@email.com"
git config --global color.ui truegit config --get remote.origin.urlgit remote -v
git remote add origin <url>
git remote set-url origin <url>Branch is just a pointer in the git DB HEAD is your current branch, parent of your last commit,
To see all the heads:
find git/.refsMerge modify the branch
Merge conflicts tool:
git mergetoolgit merge --nocommit (merge but it does not commit)- Try out an idea, a new feature
- Isolate work units
- Long running topic
git push origin masterfetch gets latest master from origin
git fetchpull == fetch + merge
git pullThe history of the commits
git logFormatting the result
git log --oneline
git log --oneline --graph --all --decorategit config --global alias.lol "log --oneline --graph --all --decorate"git config --global alias.gisquash 'git reset --soft HEAD~$(git rev-list --count HEAD ^master)'More here