Git is a version control system. Basically, if someone changes a file (like opens a document and writes stuff in it, changes a line of code, or so on) it records the differences between the new version and the old version, and maintains a history. This allows people to preserve differing versions, go back in time to earlier ones, review changes as they have occurred over time, and so on.

What is it?

  • VCS - Version Control System
  • Snapshots, not differences, nor deltas
  • Series of snapshots of a tiny filesystem
  • Every commit is a new snapshot
    no changes no new file stored
  • Everything is local
    Offline!
  • Every file is checksummed!

Why git?

  • Everything is code

  • File syncing

  • Version history of text files

  • DevOps

  • Configuration as Code

  • Infrastructure as Code

GitHub freebies

  • Markdown is rendered

  • Markdown just works well in git

  • GitHub Pages offers free static hosting and CMS

  • or old school text files are fine too

How git?

make files

add  
commit  
push

Git Cheat Sheet: https://education.github.com/git-cheat-sheet-education.pdf

You will mess up

  • It’s ok
  • It’s all just files anyway
  • ohshitgit.com
  • keep notes of git commands
cd ../  
rm -rf my-git-repo  
git clone https://github.com/myuser/my-git-repo.git  

Git branching

  • Everyone always uses master
  • don’t
  • lazy/bad habit
  • You aren’t sole contributor

Feature branches

  • Your ‘Changeset’ is a branch
  • Then commit, push/merge, PR
  • order in the chaos

Simple workflow

  • Pull from master
git branch harwinder  
git checkout harwinder
  • change files
git commit -a -m "my message"  
git push origin harwinder; #my branch  
  • open pull request

Commit messages

  • Re-establishing the context of a piece of code is wasteful
  • We can’t avoid it completely, so our efforts go to reducing it as much as possible
  • Commit Messages can do exactly that & as a result, a commit message shows whether a developer is a good collaborator

Commit squashing

  • squash before PR
  • Cleaner
  • Rewrite bad commit messages

Protect yourself