Git commits: please mark your stitches!

[This article was first published on Maëlle's R blog on Maëlle Salmon's personal website, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In which I share a crochet analogy for Git commits…

Don’t forget your stitch markers!

I am happily continuing my crochet learning journey. One lesson I have now internalised is that I should never ever forget or neglect to use stitch markers. Stitch markers are sort of small, not spiky, safety pins.

A crochet project featuring several stitch markers (beginning of a Snorlax from Lee Sartori’s Pokemon crochet book)

A crochet project featuring several stitch markers (beginning of a Snorlax from Lee Sartori’s Pokemon crochet book)

Stitch markers should be used:

  • at the beginning of a round to not forget where it started – in amigurumi you often crochet in a spiral so it’s hard to know where a round started,
  • every multiple of stitches to not have to count stitches above 12 even if you happen to have a PhD in counting1. Many crochet patterns will have you, say, “increase by two stitches every 8th stitch”, then “increase by two stitches every 9th stitch” so having your markers every 9 then 10 stitches will be most helpful.

I have sometimes forgotten to place my stitch marker at the beginning of a round, and really regretted my lack of concentration. Furthermore, I used to think that adding more stitch markers was too much work (Opening the marker! Putting it under a stitch! Closing the marker! Could I be any lazier?!) which is absolutely wrong. Stitch markers bring peace of mind. They spark joy.

Don’t forget your Git commits!

Well, Git commits are just like stitch markers. Putting them regularly along your strand of work will only help you in the future. It is well worth the small annoyance of making them. With good commits, you can undo your work up to a certain point. You can understand what was done when and why.

In the saperlipopette R package I’ve recently added exercises related to using history:

Most of those exercises teach you the skill of obtaining a Git commit ID in answer to a question. How useful that is depends on how good the commit history is: big commits with uninformative messages are not great. If the exercises related to using the history seem relevant to you, try improving your commit history.

Screenshot of commits on saperlipopette's GitHub repo where each type of commit gets a colored label, e.g. 'docs' or 'feature'

Note that you use conventional commits, you might even get nice colours for them, just as if you were using stitch markers! The above is due to RefinedGitHub, a browser extension for GitHub, but I’m sure similar functionality exist for other Git platforms and in IDEs.

Conclusion

In conclusion, I firmly believe good Git commits can change your life for the better, just like stitch markers. Don’t learn the lesson the hard way!

Besides, if you’re interested in learning how to recover from common Git mistakes such as a commit made on the wrong branch, consider registering to my upcoming workshop at Workshops for Ukraine: “Oops, Git! How to recover from common mistakes”, Thursday, March 19th, 14:00 – 16:00 CET (Rome, Berlin, Paris timezone). All proceeds going to support Ukraine. (After the workshop, making a donation gets you access to the recording)


  1. Also called PhD in statistics! ↩︎

To leave a comment for the author, please follow the link and comment on their blog: Maëlle's R blog on Maëlle Salmon's personal website.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)