Git, GitHub for 59X

A 59x jawn

Slides by Ruthie

Goals

  • refresh git knowledge
  • choose a dev flow
  • submit proposal by tomorrow night

Rough guide:

  • git is a program
  • git is distributed
  • git needs some configuration
  • git has a lifecycle
  • learn the commit model
  • merge calmly
  • a possible flow

git is a program

  • it runs on your computer
  • do you have it? which git
  • in order to use git on a particular project you have to init

git is distributed

  • it's a program and can run on servers
  • you'll need to clone a repo from a link or push it up

Git needs setup

  • check for your username: git config user.name
  • set it if it isn't set: git config --global user.name "Princess Ruthie"
  • same for your user.email

Lifecycle

The commit model

  • commits have pointers to a snapshot "tree"
  • the "tree" has pointers to all the commit's blobs
  • commits have pointers to parent commits

More commit model

  • commits also have have committer name and email
  • ex: I make commit 2a04d and then I make commit f33bc
  • Where does f33bc point to? Whose the parent? How about 2a04d?

Branch

  • a branch is a pointer to a commit

git branch

  • when you branch, you make a branch. git branch cool-new-branch
  • what's a branch?
  • when you branch, all you do is make a branch

HEAD

  • HEAD is a pointer to a branch. You only have one.
  • if you only have one branch, where does HEAD point?
  • if you want to point to a different branch git checkout branch-name
  • where does HEAD point now?

merge, conflict

  • Check the pdf

merge

  • Check the pdf

Quick, dirty

  • git clone [wherever the repo is]
  • git log
  • git status
  • ~~change a file and save~~
  • git add [filename or a period]
  • git commit -m "feat: Implement BFS for karel" **avoids using vim
  • git push
  • git reset [filename or just a period]

Commit messages matter

  • start with feat/fix/doc/refactor etc
  • then add succent message in like imperative voice
  • ex: feat: Implement image slider
  • ex: doc: Add license

your team

  • pdf/md gives you a 7-step setup
  • it's foolproof but there a zillion other options

Now

  1. Clone your repo
  2. read the log
  3. get the status
  4. make a change and stage used 'add'
  5. commit the change with a helpful message

Undoing stuff

You can do this by accident. Edit a file, save but don't commit.

git checkout [name of a file that you've changed]

boom. your changes all sad and gone.

Ignorance is bliss

Not everything should go to the cloud. EVEN in private repos. Use a .ignore file to keep these files safe/local.

  • passwords
  • keys
  • IDE config files
  • lets do our own and then
  • check out

Thing to know

  • git tracks CHANGES. Can think like a bank account where to undo, you just change signs and rerun transactions in reverse order to get to a previous balance.