Azure DevOps, Scrum, & .NET Software Leadership and Consulting Services

Introducing Slide Speaker: Videos with Voice-over from your PowerPoint and Google Slides Presentations

Lazy Commit: A single gitconfig alias for stage, commit, and push


I’ve been doing a fair bit of development with GitHub Actions lately for continuous integration and continuous deploy pipelines (CI/CD). Here’s what the process has been like: try something in the YAML file for the build, commit something to cause the GitHub Action to run, see why it failed, repeat.

In the beginning, my git commit messages were descriptive…but after the 90 zillionth trial-and-error commit, they started getting less and less descriptive. What I really wanted was a way to quickly commit changes and push the changes to the Github remote.

My solution was to create an alias in my gitconfig that would:

  1. Stage my changes
  2. Commit my changes with a simple auto-generated message with the current date/time
  3. Push my changes to the remote repository

Here it is. Add this to your .gitconfig and then you can run “git lazy” to trigger this.

[alias] lazy = "!f() { msg='lazy commit: '$( date '+%F_%H:%M:%S' ); git stage .; git commit -m \"$msg\"; git push; }; f"

BTW, make sure that that’s all on one line in your .gitconfig.

I hope this helps,
-Ben


— Looking for help with git or GitHub or Azure DevOps? GitHub Actions got you down? Azure DevOps Pipelines bumming you out? We can help. Drop us a line at info@benday.com.

SUBSCRIBE TO THE BLOG


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.