March 29, 2024

Make Checkpoint

aka How a Makefile Improves my Side Projects
edit

When I’m working on production code, I tend to be really good about making atomic commits in git. I’m a big fan of using patch commits, git commit -p, to be really precise about what I am adding in that commit.

But when I’m prototyping or working on a new side project, throw that all out the window!

I’m really bad about it on a side project. I can’t tell you how many times I’ve written entire projects without making a single commit. It’s truly laughable. I have to do better, and luckily, it’s easy to do so.

I originally learned this tip from Brandon Dail on Twitter. The tip is to use a Makefile to create a script that generates a “checkpoint”, a git commit with a timestamp.

We’ll add a new file to our project named Makefile, and then add the following to it:

checkpoint:
	@git add -A
	@git commit -m "checkpoint at $$(date '+%Y-%m-%dT%H:%M:%S%z')"
	@git push
	@echo Checkpoint created and pushed to remote

Now, in the terminal, I can run the command make checkpoint and it does the following:

  • Stages all the files to be committed
  • Commits them with a message of “checkpoint at <timestamp>“
  • Pushes the branch
  • Logs out that the work is done

It’s that simple.

Now when I’m jamming on a new idea, I don’t have to worry about my poor committing habits, I can just make checkpoints, which is way better than nothing.

So if you’re like me and really lazy about git while hacking on something, consider adding this to your next project. Might help you out a little bit.


Liked the post?
Give the author a dopamine boost with a few "beard strokes". Click the beard up to 50 times to show your appreciation.
Kyle Shevlin's face, which is mostly a beard with eyes

Kyle Shevlin is the founder & lead software engineer of Agathist, a software development firm with a mission to build good software with good people.

Logo for Data Structures and Algorithms
Data Structures and Algorithms
Check out my courses!
If you enjoy my posts, you might enjoy my courses, too. Click the button to view the course or go to Courses for more information.
Sign up for my newsletter
Let's chat some more about TypeScript, React, and frontend web development. Unsubscribe at any time.