Ask HN: How to give a crash course on Git?
1–10 of 34 posts
Re: Ask HN: How to give a crash course on Git?
#2Re: Ask HN: How to give a crash course on Git?
#3Re: Ask HN: How to give a crash course on Git?
#4if you are designing a quick teaching tool or a training session, make warning messages that are informative, motivational, and kinda scary depending on the result (e.g., git commit with message is good, here's a sparkly high five; merge to main w/o code review is scary; squash commits is scary; committing credentials and pushing to prod is scary). Consider designing the lesson around lawful/true/chaotic evil/neutral/good. And then when not great things happen, have them try to fix the issue (rebase, reset commits hard/soft, rollback merge to main, ask for help when you don't know, inform someone else that you've made an error). This way they know informing others that something not great has happened and asking for help are good. Design the lesson such that best practice is standard practice.
Re: Ask HN: How to give a crash course on Git?
#5Re: Ask HN: How to give a crash course on Git?
#6Windows novices may not realise that git can be a local program contained in a folder, so making a repo to test how a verb works costs you nothing.
Re: Ask HN: How to give a crash course on Git?
#7Also explain that GIT stores files by the MD5 hash of their contents, show him the hidden .git folder, explain its structure, and the object folder, with all the subfolders and files
Everything else is pointers, and chains of pointers, to those snapshot files, with some labels.
---
It took me way too long to grok GIT because I was under the mistake impression that it stored deltas, and that made it much, much harder to understand
---
In Windows, "git gui" is a pretty darned usable GUI
Re: Ask HN: How to give a crash course on Git?
#8If he's truly a novice, then he's not an anything-guy yet (hopefully). Just teach him what you know and let him to discover GUI tools by himself if he's so inclined.
Re: Ask HN: How to give a crash course on Git?
#9Set up a Virtual Box + CLI. if you are designing a quick teaching tool or a training session, make warning messages that are informative, motivational, and kinda scary depending on the result (e.g., git commit with message is good, here's a sparkly high five; merge to main w/o code review is scary; squash commits is scary; committing credentials and pushing to prod is scary). Consider designing the lesson around lawf…
Re: Ask HN: How to give a crash course on Git?
#10Deeper understanding of git can happen gradually. For now he just needs to be able to do a basic workflow.
################################
# download a new project to local disk
cd ~/projects
git clone someUrl
################################
# get latest code
git pull
################################
# observe the general state of things.
# Run status liberally, before/after any git operation.
git status
################################
# commit changes and push them up the the server.
# This is the bread an butter of your git usage.
git add .
git commit
# good idea to pull in the latest changes before you push up.
git pull
git push
################################
# resolve merge conflicts after a pull
git pull
# alert merge conflicts! git status will tell you which files conflict.
git status
# edit each file with conflicts. Conflicts are flagged in file with ">>>>"
# replace the ">>>>" sections with the final resolved code.
# now check them in and push up the the server.
git add .
git commit
git push
################################
# develop in a feature branch
git checkout -b featureX
# make changes like nomral. add, commit your changes.
# if this is a private branch on your local box only, you do not push.
git add .
git commit
# periodically pull in the code from the parent branch so you don't drift apart
git fetch origin
git rebase origin/master
# feature complete. Merge feature back to master.
git checkout master
git pull # get latest master code
git merge featureX
git push