Lazygit: Simple terminal UI for Git commands
github.com
github.com
I'd like to share some of my thoughts about the comparison.
lazygit is a TUI for git which can behave in a standalone fashion. It's also designed to be quick and easy to use to perform quite advanced actions but ones that a seasoned git user may really want when working with git history. Since I'm already a seasoned git user the main feature I like about lazygit is the ability to surgically work with patches.
All that said, a majority of my workflow is tightly bound to git-fuzzy. I use its CLI composability quite heavily in combination with aliases and functions - git-fuzzy excels in this particular way (`git fuzzy log $(git fuzzy branch)` which I invoke using `gl $(gb)` by way of aliases). git-fuzzy is better for working with git-log or git-reflog and interactively searching them.
I personally quite like what I made (for myself), though I wish there was a world where I could quickly and easily mash both of these projects together.
Are there other apps that offer scriptable GUIs ?
Isn't this the essence of "plugins" in most GUI apps?
I have 5 un-pushed commits. I missed a 1-line change to that first one. I add that one line change to staging (gitui/lazygit/whatever), then I want to `git commit --fixup=COMMIT`. Finding that COMMIT is always a manual process for me for two reasons.
First I have to find the commit to which it applies. This commit is almost always the commit that changed the same line, or added lines around it, or something similar. I guess you could say it's the commit with the closest proximity to the change I'm adding.
Second I have to find the hash of that commit. If I've since done something like an autosquash rebase then it'll have changed. I generally end up using the mouse to do a copy/paste at this point.
Why not skip the fixup commits and just rebase right then, you might ask. Well the commits are signed, and signing requires tapping my yubikey for each commit after that.
I would really like to be able to do something like `git commit --I'm-an-idiot-and-missed-this-so-please-apply-a-fixup-to-the-proper-commit`, and have it do the figuring out for me.
Thanks for the tip!
If you've already made the change but haven't committed it, you can stash it before doing the rebase, then pop the stash while editing that commit.
frbi = "!f() { git rebase -i $(git log --pretty=oneline --color=always | fzf --ansi | cut -d ' ' -f1)^ ; }; f"
I do: `git frbi` (which in my mind means Fzf ReBase Interactive)Then I can easily scroll up to the commit I want to start the rebase on.
git commit --fixup=':/message regexp'
This will find the youngest commit where the message matches the "message regexp" pattern.
See also: https://git-scm.com/docs/gitrevisionsThis looks like exactly what I wanted. Thank you!
Feel free to make a PR. If not, I'll probably queue it up to work on at some point.
It’s not quite as automatic as you describe, but it’s super quick if you vaguely know what commit you want to amend and there’s no magic happening: just a good ui
fzf (absolutely incredible tool with many uses) gives you fuzzy searching of anything you care to name, and fzf-git combines this with shell key bindings to let you pop up a fuzzy-searchable list of branches/commits/tags/whatever while typing your fixup command, then paste the object you select into your in-progress command line.
No more counting commits in log output to know how many ^ to put after HEAD, or copying out segments of commit SHAs!
The way to work with it is:
git add file1
git commit -m "Fix some bug in file1"
git add file2
git commit -m "Add a feature flag for file1"
# Oh no, first commit was borked, need to fix it
git add file1
git absorb
# this will now automatically create one or more fixup commits
git rebase -i --autosquash $(git merge-base master)
# voila, tidy history and each commit worksWith lazygit, I never missed that feeling of control. All commands are printed and rather complicated rebases become a breeze. Highly appreciate this tool! :)
[1] https://youtrack.jetbrains.com/issue/IDEA-186988/Allow-commi...
In Rider, there are features that allow committing individual lines instead of a whole file. You can select in the commit dialog which lines to include/omit. Also I recommended taking a look at Changelists feature that allows separating certain changes from what would be committed next (I believe it works line by line basis).
[1] https://blog.jetbrains.com/idea/2023/06/intellij-idea-2023-2...
I'm glad people still build these TUIs, that's exactly what i need, simple interaction with my keyboard, no fuss, no bloat (edit: just checked, the executable is pretty large ~5mb, I wish Go made some effort in that area), a simple executable that can run on my headless server through SSH
My main factor is I don't want to have to context switch across applications. I don't feel like I'm doing that if I stay in the terminal. As such, I would imagine if I were a VSCode user, I'd prefer a git plugin there.
VCS is very much tied to the code, so I think it makes sense to co-locate.
I use helix as an editor and like to use a range of command line tools and scripts for regular stuff. Lazygit fits right into that and I don't have to leave the terminal.
I used vs-code a few years ago and its got plugin was (I assume still is) pretty good, if I used it as my editor then I'd probably use a plug in like you say, but as things are lazygit is both an awesome tool and the path of least resistance.
There is a small learning curve for the commands but it's minor compared to the intuitive control you get. A lot of the dedicated tools are just too bloated and use different terminology than the git standard which baffles me.
My colleague will use source tree and Everytime I see him doing stuff I always think : "But that's not what the got command is called for that".
Lazygit for me brings over the feature that made GitX the greatest and that was the way it allowed to quickly and easily select a few lines of changes from each file and add them to the index for commit or amend them to a different commit. Lazygit even ramps this up with a lot of nice tooling around interactive rebase (like reordering, editing commits directly, squasing, deleting commits, reword, etc) which makes it a feast instead of a file editing/context juggling chore.
lazygit makes it super easy to make modifications. Reorder commits, revert specific hunks from commits. I find it easier to use if I need to look at a really big diff. I reach for it instead of `git rebase -i`, and it can do things no native tool can do easily (such as revert or extract specific hunks from commit earlier in the tree.
I use both multiple times per day. tig if I just want to look at stuff (fewer keystrokes to look at diffs in the tui!) and lazygit if I want to modify stuff (more powerful!).
A new version just came out today https://github.com/jesseduffield/lazygit/releases/tag/v0.39....
In the next release we're adding worktree support: if you use worktrees in your daily flow I'd love to know what that flow looks like and what your pain points are so feel free to join the discussion here: https://github.com/jesseduffield/lazygit/discussions/2803
Otherwise Magit is a fantastic piece of software :D
But anyway, I typically have it sitting quietly in a terminal pane and just use it for selecting files/hunks/lines for easy commit message editing. It's great for that.
I'm not particularly keen to have my VCS and my code editing in the same software really, although I wouldn't say that it's a superior approach.
I tried the git thing that’s part of vscode and it really wants me to click. It is theoretically possible to get by without, but it’s cumbersome.
Addendum: I'm also not always using VSCode. Sometimes I just use vim if I'm already in my terminal and it's a small edit, at which point I don't want to have to go back to VSCode (potentially having to open the project) just for git