Eric / Brooklyn

Random 5

Operator as Methods

Web Accounts

Honeypot Bots

Stripe and Tap

Git Save

Whitespace Problems

Ruby Exits

Appending in Javascript

Sendgrid Ban

Clean URLs

Integer Division

Multi-tab Websockets

Bad Content

JS Data Chutzpah

Responsive tables



Emoji Bits


Ruby vs. Ruby

Extending Devise

Rails UJS

ENV Variables

See All

Git Save

Feb 2023


Back in the days before everything auto-saved, we actually had to remember to save things.

It wasn’t all that painful, aside from the occasional unsaved app crashing fiasco. It gave a moment to pause, reflect, and mark a point in progress.

Autosave has eliminated these pause breaks for nearly all computer-related work, though one exception comes to mind: programming.

Version control forces us to pause every now and again, and deliberately mark a save point for our work. Whether or not this pause break is a peaceful moment of reflection is another question.

These pause breaks look something like:

git add -A
git c -m 'my commit message'
git push

This is fine, but it can be a bit tedious - stage, commit, push each time.

The temporary pause is refreshing, though perhaps we can reduce the number of steps required.

Let’s try to make our pause-break resemble a single command S.

git save

Here’s how:

git config --global '!f() { message=${1:-"default message"}; git add -A && git commit -m "$message" && git push; }; f'

This works right out of the box. Typing git save will stage all files, create a commit with “default message” (or whatever we replace “default message” with), and then push the files.

If we want to specify the commit message, we can say git save 'my custom message' and we’re on our way.


Create the git alias save

git config --global

Create a shell function and then call it.

'!f() { ... }; f'

Create a default message, or take one is as the first argument.

message=${1:-"default message"};

Stage, commit, and then push.

git add -A && git commit -m "$message" && git push; 

And altogether again:

git config --global '!f() { message=${1:-"default message"}; git add -A && git commit -m "$message" && git push; }; f'