I have done an interactive tutorial of git for beginners. It explains the commands: init, add, commit, status, diff, log.
It also has an interactive cheatsheet.
I really appreciate if you could look at it and comment on if you find it useful with respect of the experiences you have in teaching git.
Also any correction on the text of the tutorial is welcome as I am not a native english speaker.
code in github
Pretty cool! I’ll look at it in depth over the week-end
This is really cool. I love the way you’ve split out the working, staging, and repository areas visually. I find that this three-statge-thinking paradigm is the most important concept to get across to new Git users.
Once they understand that, everything clicks.
Daniel, this is awesome work. I hope you’re able to keep adding to it, as it’s definitely something I’ll use in my classes.
Thanks John, I think the same about the 3 areas.
I have pending to add more information on the benefits of having this 3 steps.
The staging area seems useless to beginners because of the “linear” flow (modify -> add -> commit) of most tutorials and simple tasks.
But the flow gets complicated when working on real projects. You modify a bunch of files and not all are related to a single unit work (commit). So having the staging area to “prepare” the commits is really useful.
Also if you are doing something easy, you can use
commit -a and don’t worry about the staging area.
Thanks, I am thinking of just adding something about remote repositories and that’s all. I am curious of what other features you would like to see.
There is also Learn git branching that is an amazing resource to teach merge, branch, pull, fetch, etc.
Can you share a little bit more about what kind of classes you teach and how will this tutorial help you.
When I teach about the staging area I use two metaphors: a shopping cart and a rough draft.
You can put things into your cart and take them out until you are ready to commit.
The staging area is a rough draft of a commit, you can
git add to it and
git reset parts of it until it’s just right. Then you save the draft permanently into your repository history as a commit with
I like the shopping cart metaphor, it is really cool!
Thanks for this Daniel
I think that visualising the working vs staging area like this is definitely helpful and I’ve been thinking about I can try and demonstrate this in a visual way in a lecture theatre - especially using a metaphor such as envelopes of something
The problem I face, and I think that your demonstrator suffers from too, is that what it shows is not what is happening in git. It appears that the files move from the working copy into the index on a git add, then move into the repository on a git commit, which is not the case.
Git add adds the file to the repository (or at least created an object for that file), and
git commit creates a commit object that sets that file in the history.
I think I’m conflicted about whether it is ok for students to have an understanding of git that is inaccurate but enough to get them using it, or whether they ought to learn what is actually happening - which in truth is not all that complicated.
Hope this doesn’t sound like a criticism of what you’ve done - it’s impressive - it’s just that it’s tapped into a personal agony on the subject.
Thanks for your comment Richard, it is an interesting thought.
I think your idea can be generalized to how in depth we need to explain something, or search for a simpler analogy just to make getting started easier.
It is a fair question to ask, and maybe it has multiple answers as well as pros and cons of each way.
I find this to be similar to how math is taught. Many times, our teachers lie to us about things at first to get the concept through and then reveal the inner workings later. For example, I was told that one could not subtract a number from another number that was smaller when I was in primary school. It seemed logical at the time, until I learned of negative numbers.
I have mixed opinions on tactics like this, and I think it comes down to the teacher assessing how much the students can handle at one time. I often teach Git with a second terminal open running the command
watch -n .25 tree .git to show the files being created on disk in real time as the
git add and
git commit commands are run.
I like this tutorial, covers the basics.
I’d also like to mention that if you want something that goes a little further (ex. remotes), there’s also https://try.github.io/
That’s a nice way to show what is happening. It’s similar to what is shown in this superb course which unfortunately must be paid for - https://www.pluralsight.com/courses/how-git-works