Readit News logoReadit News
parentheses · 2 years ago
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.

[0] https://github.com/bigH/git-fuzzy

kenmacd · 2 years ago
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.

fla · 2 years ago
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
mklein994 · 2 years ago
Not as quick as you're asking for, but what I do, after running "git log" to jog my memory of what the commit message was, is this:

  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/gitrevisions

hashhar · 2 years ago
Boy have I got the thing for you. git absorb - https://github.com/tummychow/git-absorb

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 works

shambulatron · 2 years ago
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!

spost · 2 years ago
https://github.com/tummychow/git-absorb Does a very nice job of this for me.
williamdclt · 2 years ago
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

dceddia · 2 years ago
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.
brantonb · 2 years ago
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.
jesseduffield · 2 years ago
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.

PR: https://github.com/jesseduffield/lazygit/pull/2654

parentheses · 2 years ago
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.

xuhu · 2 years ago
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.

Are there other apps that offer scriptable GUIs ?

gpderetta · 2 years ago
Emacs (which, incidentally, uses a lisp for scripting, like autocad).
nerdponx · 2 years ago
> Are there other apps that offer scriptable GUIs

Isn't this the essence of "plugins" in most GUI apps?

shadowfox · 2 years ago
I vaguely remember doing similar things with Matlab, but it has been a while and I don't recollect fully.
masukomi · 2 years ago
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.
EinLama · 2 years ago
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! :)

vistu · 2 years ago
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.
fknorangesite · 2 years ago
This YouTube video is linked from the README: https://www.youtube.com/watch?v=CPLdltN7wgE
FrontAid · 2 years ago
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].

[1] https://youtrack.jetbrains.com/issue/IDEA-186988/Allow-commi...

[2] https://github.com/frontaid/git-cli-tools#clients

jcurtis · 2 years ago
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.

[1] https://blog.jetbrains.com/idea/2023/06/intellij-idea-2023-2...

FrontAid · 2 years ago
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.
tomkarho · 2 years ago
Is this something missing specifically from IDEA?

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).

FrontAid · 2 years ago
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).
sugarpile · 2 years ago
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)
hahn-kev · 2 years ago
MacOS only
CSSer · 2 years ago
Wow. VS Code can do that.
darkvertex · 2 years ago
It's nice but I prefer https://github.com/extrawurst/gitui cause it's a little snappier.
Patrickmi · 2 years ago
Of course it’s written in rust
gregmfoster · 2 years ago
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
ar_lan · 2 years ago
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.

bilekas · 2 years ago
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".

benrutter · 2 years ago
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.

WhereIsTheTruth · 2 years ago
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

piuantiderp · 2 years ago
Emacs has had this forever...
heywire · 2 years ago
The built in support for git in Visual Studio 2022 is pretty good, but I do occasionally find myself reaching for the command line still.
hahn-kev · 2 years ago
Jetbrains has this down so well. I sometimes wish I could open up a light weight version of their IDE just for git management.
tcfunk · 2 years ago
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).
aequitas · 2 years ago
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.