I found lazygit after building something of my own thay solves some of these problems for me - git-fuzzy [0].
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.
Interesting project... in the hopes of maybe nerd-sniping you (or having someone tell me where it already exists), I'll tell you the story I'd really like a solution to but can never seem to find time to build:
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.
I usually solve this by commiting my fixup in a dummy commit, then do a rebase -i HEAD~n where n is the number of commits I want to look back at. Then during the rebase I just move my commit below the one that seem the most appropriate and mark it for squash. Execute the rebase. Done
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 works
This was my bugbear for a long time too, and then I found fzf-git.sh (actually its PowerShell equivalent, PSFzf).
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!
Lazygit allows you to easily « add » your stated changes to any commit (doing a rebase under the hood). Stage stuff, find the commit (the UI helps to quickly find the right commit) and press « a » for amend.
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
I do this a lot in lazygit, or at least something that sounds similar: I’ve got some changes, I stage them by pressing spacebar (or hitting enter and adding lines in a more granular way), and then switch to the Commits tab, arrow down to the one I want to add this change to (all the unpushed ones are red) and hit A to amend.
I can’t solve the whole problem for you, but you can `git commit --fixup HEAD~4` if you know it’s 5 commits back. No need to figure out the hash. `HEAD^^^^` would also work — sometimes if I have to repeatedly fixup the same commit, adding an additional ^ to a previous command is easiest.
Lazygit maintainer here: I've found myself in your shoes quite a bit (without the commit signing part) and a few weeks ago I put up a draft PR where if a file is selected, it highlights the commits that touch that file. Typically you want to amend the most recent commit that changed the file and typically that commit is visible without needing to scroll. But I haven't spent much time thinking about what the ideal UX is, how to activate it, etc.
I want this too. We just shipped "amend from status" allowing you to push staged files into the HEAD commit. It's only a small step to add selection of the commit to amend.
Feel free to make a PR. If not, I'll probably queue it up to work on at some point.
Of tools that mash interactive GUIs (lazygit) with scriptable shells (git fuzzy), I only know of AutoCAD. Scripts would routinely ask you to interactively select a set of points or an item in a list.
thanks for this. I love the _idea_ of lazygit but I've never managed to work it into my workflow. git-fuzzy looks _much_ more inline with something that I'd be likely to keep using and I'm definitely going to give it a shot. I've got something similar for fuzzy picking branches and it's been great.
I'm using this tool for a couple of months now and I fully enjoy it. I was always the CLI type when it comes to using git. I never liked the ambiguity that regular UI tools introduced. I want to know which git commands are being executed when I click a button or drag and drop a commit.
With lazygit, I never missed that feeling of control. All commands are printed and rather complicated rebases become a breeze. Highly appreciate this tool! :)
Looks rather nice when looking at, but I have to say that (for me) the animations in the github page are way to fast to get any feeling of what the tool does.
I use IntelliJ IDEA and often rely on their own Git functionality. But it cannot stage specific lines, only whole chunks [1]. For that, I've been using lazygit for a couple of months now. I like its simple UI and that it makes staging specific lines very easy and quick. If you like lazygit, you might also be interested in similar Git CLI clients that I collected here [2].
Unless I'm misunderstanding your comment, this feature is actually included in the latest EAP/beta releases[1]. There is discussion of it at the bottom of the issue you linked.
Yes, that's it. Judging from the screencast, I will continue using lazygit for that though. Not a fan of all the clicking. Hopefully there will be a keystroke available for it.
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).
I don't know Rider, but I assume this is a limitation in all of their IDEs. Yes, you can commit only certain changes within a file. But you can only do that based on whole chunks. For example, if you add two new lines at the end of an existing file, you cannot commit only one line but not the other. The same limitation applies to changelists (at least in IntelliJ IDEA and Webstorm).
FWIW, the per line staging functionality in GitUp (https://gitup.co/) is quite easy and straightforward. Very lightweight program that you can open via cli (`gitup` when in a git directory)
I'm curious how much people prefer TUIs over editor-plugin-GUIs these days. I'm getting more and more persuaded by the plugin model personally - perhaps partly by how easy it is to discover, install, update, uninstall, etc VSCode plugins
I prefer it, but I also prefer to stick to the terminal as much as possible. If I were a VSCode user, I might disagree.
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.
Recently for conflict resolving i will open up vs code. I find it so much more reliable and convenient there. I can quickly see the conflicts resolve then stage. But when it comes to more detailed things nothing compares to the cli.
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".
I don't know if it's a "I want a TUI rather than a plug-in" vibe. For me, it's more of a "it fits my workflow".
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.
The state of desktop application is pretty alarming, everything is its own web browser..
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
I love this app, use it every day. Very seldom do I need to drop out of it to run a specific command (and even then it’s probably capable of doing it and I’ve just not bothered to figure out how).
There used to be GitX for macOS, which was a very nice, lightweight GUI tool. Sadly it is no longer maintained. There are a few forks though, but they all seem to hang or crash in their own unique way making them unusable for me.
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.
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.
[0] https://github.com/bigH/git-fuzzy
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.
The way to work with it is:
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!
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
PR: https://github.com/jesseduffield/lazygit/pull/2654
Feel free to make a PR. If not, I'll probably queue it up to work on at some point.
Are there other apps that offer scriptable GUIs ?
Isn't this the essence of "plugins" in most GUI apps?
With 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...
[2] https://github.com/frontaid/git-cli-tools#clients
[1] https://blog.jetbrains.com/idea/2023/06/intellij-idea-2023-2...
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).
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.
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".
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.
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
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.