Live data from Hacker News

Ask HN: How to give a crash course on Git?

news.ycombinator.com

1–10 of 34 posts

Ask HN: How to give a crash course on Git?

#1
I'm trying to build an application with a novice programmer. I need to teach him the fundamentals of working with Git and I'm hoping to find an approach that he won't find overwhelming. I'm a Linux/CLI guy. He is a Windows/VS Code guy. He has almost no familiarity with Git. I know he will be much more comfortable using GUI tools. The problem is that using Git through a GUI is very counter-intuitive for me. Do I need to just bite the bullet and spend a few days trying to familiarize myself with the tools he will be using or can I separate the technology from the tools when trying to teach him? More broadly, how do you approach teaching someone something differently than you would do it yourself?

Re: Ask HN: How to give a crash course on Git?

#4
Set 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 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?

#7
Explain that GIT takes snapshots, kind of like pkZip does, and it FAKES storing deltas.

Also 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?

#8
post #5

If 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.

He knows enough Python to build small tools that solve people's problems, but he's never really built a full application. This is very pragmatic advice, thank you.

Re: Ask HN: How to give a crash course on Git?

#9

Set 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…

This sounds like a fun project. Unfortunately, I don't have the bandwidth to tackle something like this right now. Perhaps if I every get sucked back into a tech lead role. It does make me think to look if there are any existing Git learning games.

Re: Ask HN: How to give a crash course on Git?

#10
Give him some prescriptive formulas. He can look up the magic incantation for each task he needs to do.

Deeper 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
Post reply on HN