12 ms·
Show HN: I made a git rebase TUI editor
I use interactive rebase quite often, and particularly like the editor bundled with IntelliJ. But I do not always work with IntelliJ, and am not 'fluent' with Vim, so I tried to replicate roughly the same rebase experience within a TUI. I used a small TUI OCaml project i made last year.
The notable features are:
- Move commits up and down, fixup, drop
- Rename commits from the editor (without having to stop for a reword during the rebase run)
- Visualize modified files along commits
- 'Explode' a commit ,creating a commit for each modified file (a thing I found myself doing quite often)
Feedbacks (both on the tool and the code) and contributions welcome, hope it could fit other people needs too !
- lostdog 2y agoI wish there were a good TUI for handling merge conflicts. Vimdiff seems to be the closest, but doesn't have keyboard bindings for 3-way merges. Nothing beats Meld for me, but if you're on a remote GUI-less machine, there aren't good options.
- shawn_w 2y agoemacs' smerge has always worked well for me.
- arcanemachiner 2y agoLazygit works well for merge conflicts (and many other things): https://github.com/jesseduffield/lazygit https://github.com/jesseduffield/lazygit (I am not actually sure what a three-way merge conflict is though TBH.)
- DarmokJalad1701 2y agogit-interactive-rebase-tool (https://github.com/MitMaro/git-interactive-rebase-tool https://github.com/MitMaro/git-interactive-rebase-tool) has been my go-to for many years now. It is configured using `git config --global sequence.editor interactive-rebase-tool`. See if you are able to use that interface as well. That will make it easy to use without breaking existing workflows that use `git rebase -i`. I will give it a try anyway.
- NyuB 2y agoThanks for the recommendations (which I will probably use rather than this hand-made version :P )
- morgansolis 2y agoWhat is the main purpose of the ocli project on GitHub, and how can I use it in my command-line applications?
- oniony 2y agoWent to repository expecting a Git rebase editor and found a whole world of confusion. Not sure what this project is now, it certainly does not seems to be a TUI focused on Git rebases.
- OJFord 2y agoIt seems to be a demo app for the framework described, your 'whole world of confusion' is the framework and other demo app(s): https://github.com/NyuB/ocli?tab=readme-ov-file#newbase https://github.com/NyuB/ocli?tab=readme-ov-file#newbase
- oniony 2y agoYeah, I got that eventually. I can get behind installing a focused app to give it a whirl and see how it flies, but I draw the line at worlds of confusion. I don't need that on my PC (looking at you NPM).
- Bigpet 2y agoI was confused at first too because I tabbed out and came back to it. You need to scroll down to the `Newbase` Section. It's apparently both the repo for some kind of cli framework and for the rebase tool.
- NyuB 2y agoFor my defense, I'm pretty sure used this link https://github.com/NyuB/ocli#newbase https://github.com/NyuB/ocli#newbase but the #newbase part was stripped ;)
- deleted 2y ago[deleted]
- bruwozniak 2y agoI got fairly good mileage with https://github.com/MitMaro/git-interactive-rebase-tool/ https://github.com/MitMaro/git-interactive-rebase-tool/ which has similar goal
- deleted 2y ago[deleted]
- mro_name 2y agohow is your tea different from https://opam.ocaml.org/packages/teash/ https://opam.ocaml.org/packages/teash/?
- Degorath 2y agoSorry for the less-than-useful reply, but I tried out most of the TEA TUI frameworks in OCaml and none of them worked very well or well updated. I do not recall what problem I had with that particular one, but I ended up just using raw Notty in the end.
- syntaxing 2y agoNice work! Lazygit is a pretty popular too that does git stuff via a TUI (everything from rebasing to nuking your local) [1] https://github.com/jesseduffield/lazygit https://github.com/jesseduffield/lazygit
- NyuB 2y agoWill definitely use this !
- deleted 2y ago[deleted]
- xuhu 2y agoWatching the screencast I realize how often text and an editor are a replacement for lists, treeviews, tabs, scrollbars etc. Maybe AI is the answer for enforcing the format and for discoverability since it provides GUI-like hand holding without the hassle of actually writing GUI code.
- chx 2y agoAI is never the answer. Unless ... https://hachyderm.io/@inthehands/112006855076082650 https://hachyderm.io/@inthehands/112006855076082650 > You might be surprised to learn that I actually think LLMs have the potential to be not only fun but genuinely useful. “Show me some bullshit that would be typical in this context” can be a genuinely helpful question to have answered, in code and in natural language — for brainstorming, for seeing common conventions in an unfamiliar context, for having something crappy to react to. > Alas, that does not remotely resemble how people are pitching this technology.
- heresie-dabord 2y ago> "Show me some bullshit that would be typical in this context" "Show me some bullshit that would be typical in this context... And we'll build a multi-trillion dollar investment bubble with whatever you say." Cheers! TYFTL (thank you for the laugh)
- giancarlostoro 2y agoIt could be the next version of the Emacs Doctor though. https://www.reddit.com/r/emacs/comments/14xwue3/chatgpt_visits_the_emacs_doctor/ https://www.reddit.com/r/emacs/comments/14xwue3/chatgpt_visi... Although it looks like someone had the doctor talking to ChatGPT.
- IggleSniggle 2y agoIt's not how it's being pitched, because nobody wants you to admit "bullshit" out loud, especially when it reflects the "work" that's been done for years. But it _is_ how people are actually using it; as a rubber ducking tool + autocomplete, and in that regard, I think AI has a ton of utility for a ton of creative work, especially since nobody wants to talk to actual people if they can help it...
- the_duke 2y agoI think all of this is available in lazygit as well, which seems to still be way too unknown, despite the 50k stars: https://github.com/jesseduffield/lazygit https://github.com/jesseduffield/lazygit
- amar-laksh 2y agoBloody love lazygit!
- deleted 2y ago[deleted]
- jckahn 2y agolazygit is as necessary in my life as Vim. Absolutely incredible tool!
- shafyy 2y agoFucking love lazygit
- chb 2y agoNo other TUI for git is comparable to it.
- rkangel 2y agoAll I want is a good TUI git log viewer. I'm perfectly happy to do all the operations on the command line, but navigating the log works well interactively (e.g. start as --first-parent, with single line entries and then be able to selectively show branch commits, and patches for commits). I end up with a log view and then copy and paste commit hashes to do different things. Or use Sublime Merge which is great, but doesn't work over SSH.
- skydhash 2y agoNot a great solution, but install emacs and then magit. A bit of a learning curve but works great.
- 2y ago
- hu3 2y agoI found this code interesting (not sarcasm) in demo/boiling.ml: let increase_level t = let level = match t.level with | No_Fire -> One_Fire | One_Fire -> Two_Fires | Two_Fires -> Three_Fires | Three_Fires -> Three_Fires in { t with level } ;; let decrease_level t = let level = match t.level with | No_Fire -> No_Fire | One_Fire -> No_Fire | Two_Fires -> One_Fire | Three_Fires -> Two_Fires in { t with level } ;;
- ivanjermakov 2y agoHmm, is there OCaml equivalent of Haskell's `succ`[1], which is inplemented for all sum types deriving `Enum`? It would simplify these two functions to just `succ` and `pred` [1]: https://hackage.haskell.org/package/base-4.20.0.1/docs/GHC-Enum.html#v:succ https://hackage.haskell.org/package/base-4.20.0.1/docs/GHC-E...
- kleiba 2y agoAnyone using magit?
- SoftTalker 2y agoYes. Only tool I've found that makes git usable.
- koito17 2y agoI use Magit for everything, never the Git CLI. Rebasing is very easy to do, and so is cherrypicking, looking at the ref log, etc. Never bothered learning the Git CLI since it's always seemed cumbersome compared to Magit. That is the other major advantage to Magit, the UI is discoverable, there is always a subwindow displaying all available commands and most of the commonly used flags. (Less commonly used flags can be displayed by adjusting the transient level.)
- School-Cotton 2y agoI use it, it’s great.
- _ix 2y agoI do. It works so well I've almost taken it for granted.
- ckolkey 2y agoMissed it so much in vim I started maintaining the neovim clone.
- deleted 2y ago[deleted]
- amake 2y agoIt was the killer app that got me hooked on Emacs (which I now use as my IDE and daily driver for almost everything except web browsing). Every time I see tools like this I think "ah, the normies are reimplementing Magit".
- Olshansky 2y agoIs there anyone else that enforces a simple "just squash & merge everything from PRs into main" across the entire team? I'm comfortable git fooing w/e is necessary, but ever since we adopted this, git related conversations went to almost zero. It's great.
- keybored 2y ago> Is there anyone else that enforces a simple "just squash & merge everything from PRs into main" across the entire team? No. This kind of policy has plenty of downsides[1] and the upsides are relatively minor. [1] https://news.ycombinator.com/item?id=41653892 https://news.ycombinator.com/item?id=41653892
- skydhash 2y agoThe upsides are great. PRs should be atomic, introducing changes as a set. I don’t care about the history of the branch, I only care that the changes in the PR are one unit that can be reverted as a whole. And each commit in the main branch passes the tests.
- keybored 2y agoI get those so-called upsides with `git log --first-parent`. I can view the changes as one set of changes or all of the individual ones. But I can’t relate in general to those workflows where PRs have to be tiny and revertable (why need to revert so often).
- skydhash 2y agoIt’s mostly about project management. In a project, the unit is a task. These tasks will then have discussion around then and then get assigned to the people that are going to do the implementation. After the latter is done and approved, it will be deployed and the task will be marked as done. Having your git history reflecting this is great when you need to take decisions. Because no one will care about your individual commits. Every discussion will revolve about the task. So you make the PRs a bijective relation with it, and by extension the commits on the main branch. Then for special group of tasks like features, you have a specific branch you manage the same way. The other branches you create PRs from can be as messy as you like. And your local copy is yours to do whatever you want.
- nesk_ 2y agoI’ve been using rebase-editor for years and am pretty happy with it. Maybe it could be an inspiration for you? Congrats for the release! https://github.com/sjurba/rebase-editor https://github.com/sjurba/rebase-editor
- 3D39739091 2y agoNot trying to downplay your work, making cool tools is always cool, BUT: 1. You can also just configure Git to use whatever editor you'd like. https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreeditor https://git-scm.com/docs/git-config#Documentation/git-config... 2. You don't need to be a Vim pro to interactive rebase effectively. Most of it will be `dd` to remove a line, `p` to paste a line, `j`/`k` to move up and down lines, and `cw` to change `pick` to `edit`, etc. Spend 15m with `vimtutor` (which is probably available on your system) and you'll never be afraid of vim again.
- samtheprogram 2y agoSecond this. Just change the EDITOR variable. You’re getting downvoted (probably because of the mini Vim tutorial in #2) while the author of the post wrote a whole TUI because they didn’t know to change their EDITOR variable. Learn your tools, people. This is the equivalent of a contractor taping rulers together because they didn’t realize their bag comes with a tape measure.
- unfunco 2y agoIt's GIT_EDITOR first, then EDITOR if GIT_EDITOR is not set.
- Jenk 2y agogit config --global core.editor "vim"
- codetrotter 2y agoYes, but EDITOR is also read by a lot of other tools. And if you want to use a particular editor with git, and didn’t know about EDITOR, you probably want to set EDITOR so that when other tools open an editor it will be the same one. But if you already have that and want something specific and different for just git then yeah GIT_EDITOR.
- 3D39739091 2y ago> Learn your tools, people. This is the equivalent of a contractor taping rulers together because they didn’t realize their bag comes with a tape measure. I feel like this is one of the big things we lose when working completely remote and disconnected: missing out on all these chances to help each other. We don't know the things we don't know. Imagine OP was going to do a rebase -i, sitting next to a teammate and said, "man, I would do anything to be able to use interactive rebase without having to learn vim", and their teammate turned back and said, "Oh, you can use any editor you want".