donmesswithabeer avatar

How To GIT Commit and Push to Branch on Macbook Lid Close

donmesswithabeer

Published: 03 Dec 2017 › Updated: 03 Dec 2017How To GIT Commit and Push to Branch on Macbook Lid Close

How To GIT Commit and Push to Branch on Macbook Lid Close

Alright, this is something I wanted to do because I sometimes forget to push changes or perhaps didn't want to push to the branch I'm working on. I'll show you how to auto commit and push to a specific branch on macbook lid close. In fact you can run any script on close. Its a simple 3 step process

  1. Install https://github.com/fishman/sleepwatcher
  2. Create a SH script file to run on lid close (here's mine)
#!/usr/bin/env sh

cd /path/to/branch
git checkout -b auto-save
git push -f --set-upstream origin auto-save
git add .
git commit -m "sleep autosave" --no-verify
git push -f

3 Run this command at mac startup (https://stackoverflow.com/questions/6442364/running-script-upon-login-mac)
/usr/local/sbin/sleepwatcher --verbose --sleep ./path-to-script.sh

Enjoy!

Propane-Saftey.jpg

Leave How To GIT Commit and Push to Branch on Macbook Lid Close to:

Written by

Read more #programming posts


Best Posts From donmesswithabeer

We have not curated any of donmesswithabeer's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From donmesswithabeer