Making commits to repo via repl.it

When using GitHub, one import concept is the concept of a commit

What is a commit?

A commit is a snapshot of your code at a certain point in time.

  • All of the contents of all files in your repo

  • A commit message

  • A date/time stamp

  • Information (e.g. name/email) of the person that made the commit

A commit is identified by a number called a SHA.

If you go to any repo and click where it says "Commits", you'll see a list of commits. For example in the animation below, the commits are these (in reverse order):

Why should I care?

Understanding commits can be super useful. The idea is to make sure that you do a commit any time your code get to a good place—e.g. after you've successfully completed one step of the lab, solved one part of the problem, etc.

This gives you the ability to go back in time if, later on, you find that you've gone in a wrong direction, or messed things up. You can get back to a good place.

Putting a good message on your commits also help you track your progress through the problem.

The initial commit

The following animation shows how we set up the repo, with the initial commit, connect it to GitHub, and then see the commit over on GitHub.

A second commit

Now, let's make a change and make a second commit. In this animation, we:

  1. get rid of the old comments from the previous animation

  2. add print("Hello, World!") in the code

  3. Add a commit message in the box for the commit message (this is important!)—it's the box under where it says Main

  4. is'click Commit All & Push

  5. click on the repo link so that we can see the two commits

How to continue

Rules for commits:

  • Do a new commit (like the one above) any time you finish a step of the lab successfully.

  • In your commit message, say what you did (e.g. "Finished step 4", or "Added function to draw the letter X with the turtle")

  • Click "Commit All and Push" to make sure the changes get pushed over to GitHub

  • Check on GitHub to see that your commit shows up.