News for hackers. Stuff that matters.
Re:Lazygit: Simple terminal UI for Git commands by parentheses on Wednesday July 19, 2023 @05:06AM (#36783729)
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

Re:Lazygit: Simple terminal UI for Git commands by xuhu on Wednesday July 19, 2023 @07:44AM (#36784823)
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 ?

Re:Lazygit: Simple terminal UI for Git commands by nerdponx on Wednesday July 19, 2023 @08:08AM (#36785004)
> Are there other apps that offer scriptable GUIs

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

Re:Lazygit: Simple terminal UI for Git commands by shadowfox on Wednesday July 19, 2023 @07:59AM (#36784935)
I vaguely remember doing similar things with Matlab, but it has been a while and I don't recollect fully.
Re:Lazygit: Simple terminal UI for Git commands by gpderetta on Wednesday July 19, 2023 @08:08AM (#36785011)
Emacs (which, incidentally, uses a lisp for scripting, like autocad).
Re:Lazygit: Simple terminal UI for Git commands by masukomi on Wednesday July 19, 2023 @09:23AM (#36785880)
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.
Re:Lazygit: Simple terminal UI for Git commands by kenmacd on Wednesday July 19, 2023 @10:52AM (#36787418)
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.

Re:Lazygit: Simple terminal UI for Git commands by fla on Wednesday July 19, 2023 @11:22AM (#36787927)
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
Re:Lazygit: Simple terminal UI for Git commands by Seb-C on Wednesday July 19, 2023 @11:37AM (#36788156)
Wow, I never realized that changing the order of commits in an interactive rebase was a legit operation.

Thanks for the tip!

Re:Lazygit: Simple terminal UI for Git commands by shaftway on Wednesday July 19, 2023 @02:24PM (#36790950)
Another way to handle this if you haven't made the change yet is to do a `git rebase -i head~4` (or however far back) and mark the place where the change needs to happen as "edit". Make your change, add the file, then `git rebase --continue`.

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.

Re:Lazygit: Simple terminal UI for Git commands by graton on Wednesday July 19, 2023 @03:31PM (#36791932)
If you have `fzf` installed you might try this alias.

    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.

Re:Lazygit: Simple terminal UI for Git commands by brantonb on Wednesday July 19, 2023 @11:17AM (#36787859)
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.
Re:Lazygit: Simple terminal UI for Git commands by mklein994 on Wednesday July 19, 2023 @12:42PM (#36789341)
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
Re:Lazygit: Simple terminal UI for Git commands by spost on Wednesday July 19, 2023 @12:50PM (#36789455)
https://github.com/tummychow/git-absorb Does a very nice job of this for me.
Re:Lazygit: Simple terminal UI for Git commands by kenmacd on Wednesday July 19, 2023 @04:10PM (#36792476)
>> git absorb will automatically identify which commits are safe to modify, and which staged changes belong to each of those commits. It will then write fixup! commits for each of those changes.

This looks like exactly what I wanted. Thank you!

Re:Lazygit: Simple terminal UI for Git commands by parentheses on Wednesday July 19, 2023 @01:08PM (#36789756)
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.

Re:Lazygit: Simple terminal UI for Git commands by dceddia on Wednesday July 19, 2023 @01:43PM (#36790304)
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.
Re:Lazygit: Simple terminal UI for Git commands by williamdclt on Wednesday July 19, 2023 @01:46PM (#36790353)
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

Re:Lazygit: Simple terminal UI for Git commands by kenmacd on Wednesday July 19, 2023 @04:06PM (#36792425)
Ty. I've seen similar in other tools, and I agree that it's super quick... unless you sign your commits with a key that requires a physical touch of a yubikey. Then it's <tap> <wait> <tap> <wait> for every commit that comes after the one you just modified.
Re:Lazygit: Simple terminal UI for Git commands by shambulatron on Wednesday July 19, 2023 @03:18PM (#36791762)
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!

Re:Lazygit: Simple terminal UI for Git commands by jesseduffield on Thursday July 20, 2023 @06:47PM (#36807813)
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

Re:Lazygit: Simple terminal UI for Git commands by hashhar on Friday July 21, 2023 @08:56AM (#36813211)
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