Bash tip of the day: lazygit

nocnica profile image Nočnica Fee Updated on ・1 min read

Last week I asked which bash aliases you like to use and got a ton of great responses. One that had almost universal benefit was lazygit, from Mishal:

function lazygit() {
   local message="$1"
   local push_branch="${2:-$(git rev-parse --abbrev-ref HEAD)}"
   echo "Commit Message: $message"
   echo "Push Branch: ${push_branch}"
   git add --all
   git commit -m "$message"
   git push origin "$push_branch"

I added it to bash as soon as I saw it, try it yourself!

If you have improvements or other aliases/functions for bash that you love, comment below!


Heroku is a container-based cloud Platform as a Service (PaaS). Developers use Heroku to deploy, manage, and scale modern apps. Our platform is elegant, flexible, and easy to use, offering developers the simplest path to getting their apps to market.


markdown guide

It's best to practice non-lazy Git and be explicit when you actually want to add everything. Hygienic commit messages allow you and other developers to really glean information about a series if commits.

If it's just work-in-progress, then commit as such with a WIP commit and then come back to and squash into logical commits


I think I should have clarified that you shouldn’t use lazygit on anything but your own demo projects. Hopefully the name makes it obvious :)

I should write something about git best practices!


That's fair -- although, I practice this in my personal projects as well as I always like a clean history, but everything for humans is habitual. Defaulting to thinking and atomic commits carries over into daily work IMO :)

But I'm a bit extreme, too, as I'm almost alias-less. I always type the verbose git command


If me:

git status
git add -A .
git commit -m "Upload"
git push

Usually I don't want to select all files, especially if I want to split commit into more independent steps.


I've created some bash scripts similar to Zen's as well:

Filename: gitit

git add .
git commit -m "$1"
git push

Example: gitit "init commit"

I also have one for creating new branches and pushing their upstream:

Filename: branch

git checkout -b "$1"
git push origin -u "$1"

I always use branch to make new branches that way when I use gitit to push up so it works without fail. I have a few more, but those are my most used bash scripts I use in my git flow


While I understand the need for less command lines in the terminal, I think you cannot use this shortcut all the time. Otherwise, you're using Git like SVN, which is not a good approach.

I don't recommend using "git add --all"


I am not lazy. First I run git status to see what has been modified, and/or git diff. Then git add what I want to have as part of the commit (usually git add -A, but sometime a cherry-pick is needed). Only then will I perform a git commit and a git push.

Working with Git requires some care. I use aliases, of course.


I've been creating scripts lately to ease my development, and amazingly I've never thought about this, is dead simple and useful.


i thought at first you talk about open source program called lazygit

GitHub logo jesseduffield / lazygit

simple terminal UI for git commands


CI Go Report Card GolangCI GoDoc GitHub tag TODOs

A simple terminal UI for git commands, written in Go with the gocui library.

Rant time: You've heard it before, git is powerful, but what good is that power when everything is so damn hard to do? Interactive rebasing requires you to edit a goddamn TODO file in your editor? Are you kidding me? To stage part of a file you need to use a command line program to step through each hunk and if a hunk can't be split down any further but contains code you don't want to stage, you have to edit an arcane patch file by hand? Are you KIDDING me?! Sometimes you get asked to stash your changes when switching branches only to realise that after you switch and unstash that there weren't even any conflicts and it would have been fine to just checkout the branch directly? YOU HAVE GOT TO


That's actually pretty cool! I'm going to apopt that.


Love this. Do you mind if I share it in next week’s bash tip? I’ll of course link to your great article


If you’re working on a solo project and just want to use git as a backup system, this lets you enter a single command to send all current changes up to your repository.

Totally agree that empowerment should be the theme.

And yeah that alias line is unnecessary! I’ll cut it.