Track and Commit Primer

Learning Competencies

  • Define "commit"
  • Demonstrate best practices for commit messages
  • Describe the three states of a file in git (working, staged, commit)

Summary

Git works by following all of the changes in the files inside a git tracked folder. The save point in git is called a commit. A commit is your safety net if you accidentally introduce bugs in your code. You can revert to a working state while you debug your code. It is a great idea to commit often to create more frequent save points to fall back on.

Your git commit history is visible to us, and we use it to assess your participation and engagement. Throughout the course, we'll be looking at frequency and consistency. So we encourage you to engage daily and commit often. That means: whenever you add something that works, remove something, or fix something, commit it. potential future employers might also look broadly at how often you are committing things to github to get a sense of how often you're programming.

Time Box

ActivityTime
Read5 minutes
Reflect10 minutes

Good Commit Messages

Because commits are 'save points', it is essential to write good commit messages, so you (and others) know what each commit includes.

The standard practice is to follow Git's convention and use imperative, present tense language for your commits. E.g. Use "Add readme file" (imperative) instead of "Adds readme file" (descriptive) or "Added readme file" (past tense). Programmers have a lot of weird, deeply ingrained traditions like this. Most of the time it's easier to just follow along with these conventions and not ask too many questions- unless you want a very boring, breathless history lesson from the nerds on reddit.

Excerpt from git.kernel.org

Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz" as if you are giving orders to the codebase to change its behaviour. Try to make sure your explanation can be understood without external resources. Instead of providing a URL to a mailing list archive, summarize the relevant points of the discussion.

Reflect

Open your reflections text file and answer:

  • How would you describe stage and commit to your non-tech-savvy friend?