From Git To Github

An Introduction to Version-Controlled and Collaborative Development

Hi, I’m Shauna

Assumptions:

  • At least somewhat technical
  • Have a Github account set up already
  • Have git installed locally

I’ve created my Github account. Now what?

Git vs Github

Wait…there’s a difference?

(Yes, yes there is.)

Git vs Github

Git

  • Version control system
  • Spiritual successor to Subversion
  • Manages file changes on any given system

Github

  • Value-add product
  • Centralized code hosting
  • Project management
graph LR A[Source Code]-->B[Git] B-->C[Github]

Git Essentials Crash Course

Basic Git Commands

init
creates a new repo
clone
copies an existing repo from elsewhere
branch
creates a working copy of local repo
checkout
switches to a branch from the local repo
add
adds changes to "staging area" for commit review
commit
creates a "log entry" of the changes made
push
upload changes to a remote repo
pull
download changes from a remote repo
merge
combine changes from branches, forks, or commits
remote
access repos connected to the local one

Git Workflows

graph LR files[Make changes to project]-->|add|add[Add changes to staging area] add-->|commit|commit[Save changes to repo] commit-->|edit|files
graph branch[Branch project to work]-->|edit|files[Make changes to project] files-->|add|add[Add changes to staging area] add-->|commit|commit[Save changes to repo] commit-->|merge|merge[Combine changes with original branch] merge-->|branch|branch
graph remote[Remote copy]-->|pull|local[Local copy] local-->|push|remote local-->|edit|files[Do work] files-->|commit|local

GUI Tools

  • Github Desktop
  • VSCode
  • Meld
  • Sublime Merge

Authentication Options

  • Password
    • ...uses a password
    • Preferred for cloning read-only repos
    • No initial setup
    • Dependent on client tools to avoid having to put in password on every action
  • SSH
    • Passwordless
    • Preferred for writable repos
    • A few minutes of initial setup
    • Set it and forget it

Creating & Managing Our Own Repository

Step 1: Create In Github

Step 2: Initialize Local Repo

git init

2a: Tweaking Git’s Default Branch Name

git config –global init.defaultBranch main

Step 3: Making Our First Commit

git add .

^250 git commit -m “First commit”

Step 4: Connecting Local & Remote

git remote add origin [Github repo url]

Step 5: Push To Remote

git push -u origin main

git push

Step 6: Pulling Changes

git pull

Working With Others

Forks vs Branches

Branches

  • Dependent on repo
  • Inextricably linked
  • Closely related to repo
  • Intended to be merged back into main branch (usually)

Forks

  • Based off a parent repo
  • Separate/independent
  • Not necessarily related after forking
  • Merging back to parent optional

Ownership/Source Of Truth Change

Personal Repo

graph local[local]-->remote[remote]

Forked Repo

graph upstream[upstream]-->remote[remote] remote-->local[local]

Workflow Change

Branch:

Fork:

Image source: https://training.github.com

Merging And Pull Requests

Merging Branches in Git…

git checkout main

^1500 git merge feature

…And With Github Pull Requests

Making Pull Requests

(A quick note on contribution guidelines)

Handling Incoming Pull Requests

Merge Conflicts

Questions?

Credits

Slides in Hugo and RevealJS

Other Cool Stuff

Other things Github can do, or that you can do with Github

Change All The Name Defaults!

Because inclusivity is cool, and microaggressions aren’t

Github Actions

Workflow automation

Github Organizations

For organizations or even just organizing related projects

Github Pages

Static site hosting to promote your projects or host your blog (or HTML slide decks like this one!)

Github Learning Lab

Learn Github (and other things) with Github

Github Education

Github for schools and resources for teachers

Hacktoberfest

Digital Ocean’s annual event to encourage open source contributions

Help Info