This repository contains a list of resources for learning (and teaching) how we use Git at BlackSky. The resources are as follows:
crash_course.md
- Speaking notes for a crash course in Gitslides.md
- A simple set of slides to accompany the lesson plan abovecrash_course.html
- The file you open in the browser to view the slidesindex.html
- The playground in which we will practice our git-furesources/generator.js
- The Javascript file to accompany our playground
great_commit_messages.html
- Another set of slides + speaking notes on the importance of writing great commit messages.
If you are interested in learning git, the Git Immersion tutorial is a very good one that has been kicking around for over half a decade now.
If you are interested in learning about why it is important to write good commit messages, start with this post. If you need to read the same thing from different people to believe something, maybe this post will convince you of the importance of writing good commit messages. :)
Add the following to your ~/.gitconfig
for an amazing command-line git experience:
[color]
ui = auto
[alias]
co = checkout
st = status
diffs = diff --stat
diffc = diff --cached
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
newb = "!git fetch upstream && git checkout upstream/develop && git co -b $2"
cleanup = "!git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | cut -d\"/\" -f2- | xargs git push origin --delete"
[push]
default = simple
Let's talk about each option in detail:
- Color: Colors your diffs green/red when lines are added/removed
- Aliases:
co
:git co
to checkout instead ofgit checkout
st
:git st
instead ofgit status
diffs
: Shows some information about the changes you haven't yet committed
$ git diffs package.json | 1 + webpack.config.js | 13 ++++++++++++- webpack.prod.config.js | 17 ++++++++++++++--- 3 files changed, 27 insertions(+), 4 deletions(-)
- 'diffc': Same as
git diff --cached
, which shows files you've ADDED to a commit (but not yet committed) hist
: Pretty-print your git history!newb
: Automates the "new branch" part of the workflow; fetches the latest from upstream and creates a new branch from itcleanup
: Careful with this one! This will delete all the merged branches on your origin (merged may not mean the pull-request has been accepted!)
- Push: States that
push
will only push the working branch to a target repo (rather than to all repos with a branch of the same name).
If you find you have become the person in charge of the Git Crash Course contained herein, you may be interested in updating the slides. The crash course slides are written in markdown, and you can compile them to HTML with biggie.
- Install biggie:
npm install -g biggie
- Change slide content in
slides.md
- Recompile the slides:
biggie slides.md --style ./resources/big_styles.css > crash_course.html
The slides for great_commit_messages
were painstaking crafted by hand in raw
HTML, so you'll have to forego Markup when editing those.