DEV Community

Cover image for Autocommitting

Posted on


To resolve my issue for posting more progress in such major files infrequently, so my work can be published more regularly, without thinking to open GitHub Desktop, I got off the Batch mindset, shoved my brain and face into an asylum of the MSYS2 terminal testing all types of things, to make my first Shell script, dedicated to... you already read the title.

Anyway, with this script, it will help you to commit more often (if you don't already), by assigning it to a task scheduler or cron job to be run on a consistent schedule. Its usage is simply ~/Documents/repos/123/.
This script will also name your commits by summarizing your additional changes in a compact manner.

For example, you can set this to run every day, and on other days, push your changes, which can be done by appending your command with -p.

Project page:

Direct script file

Warning, this was only tested with MINGW and WSL, so I don't know if it will work purely on Linux. Titles may not look the best or probably won't work AT ALL, either, but I tried, with multiple substring problems.
In total, I think this project took a third of a day, within two days.

Here's my repo I tested this script against while putting the finishing touches, it went well as you will see:

Discussion (2)

1e4_ profile image

This could end pretty badly. You shouldn't ever do this as your commits would end up being so random. Instead you should get in thr habit of commiting more often.

It doesn't matter when you commit. It matters what you commit. If you have 20 files on awaiting to be commited, take a second and instead of git add . commit files in groups relevant to what they are. Fix Bug A. Added new feature in user profiles. Fix an issue with styling on edge and safari.. etc.

Commiting the right things is way more important than commiting all the time. Also make your commit message mean something. Nothing worse than looking through a git repo and not being able to see what's changed just off the messages.

If you use github desktop it should probably be open most of the time just chilling in the background. If you use an IDE such as PHPStorm or WebStorm it has Git integrated into it.

Just please don't get in the habit of relying on an automated tool to commit.

donnaken15 profile image
Wesley Author

yeah, i get all that, but with my workflow, i add everything anyways, and if theres things i dont want to add in there yet or something, i move it out of the folder, or comment it out if i think its problematic. i still kind of made this out of habit of not committing more often (i blatantly google searched once if i should just for one sentence of advice), if even making code changes as often, because i could be making 20 lines one day and not commit that, and then on another day (say 2 weeks apart), make 40 lines and finally put that out. i'm also not very into the mindset of titling all my commits to tell what they change (a third of the time, i do though), so the random summarizer idea didn't bother me. i can also sort of get how i mentioned the frequency of putting out changes would be excessive, maybe activating the script weekly or biweekly is better in that case. maybe i could make my script focus in on comments that would be important for summarizing titles. i also close GHD unwantingly a few times, so