Lazygit: A simple terminal UI for Git commands
github.com
github.com
Kudos to the dev for the wonderful tool
PS: There is also lazydocker by same person https://github.com/jesseduffield/lazydocker
I have it hooked up to the toggleterm plugin [0]. This way I can pop layzgit and other things (gdb, ipython etc) on a floating term
Same with editors, I really want to like VS Code but in the end I just open vim by default again.
https://marketplace.visualstudio.com/items?itemName=vscodevi...
With lazygit/tig, at least there is a visual pager with shortcut letter I need to press along with a text hint about what it actually does.
I use fugitive, but haven't remembered these commands. I map what they do to shortcuts of my choosing e.g. \gad = git add; \gco = git commit; \gpus = git push etc.
> If you're a mere mortal like me and you're tired of hearing how powerful git is when in your daily life it's a powerful pain in your ass, lazygit might be for you.
I sympathise, deeply. If you've never found yourself counting lines - repeatedly, because your last attempt failed - while manually editing a hunk, then I envy you.
But being able to right-click individual lines of code to stage/unstage them is basically the only thing I use it for, since editing patch files is a pain. The tool is also very lightweight and opens instantly, which would be a reason to switch to something else if it weren't the case.
Does any GUI offer `-p` in `git commit` and `git stash`? I literally use it 10s times per day, can't live without it once I started using it.
Since using a GUI has inevitably required me to learn CLI in depth, and adds the complexity of figuring out what the hell the GUI actually did because of course it doesn't tell you, I'm basically 100% CLI as well.
I got burnt by this with svn... when unfucking things was a lot more complicated and required faster disk and connection.
I always use(d) the terminal, but Fork is the first time I am considering using a GUI as my main tool.
Granted I haven't had to do anything complicated yet with it, so I don't know if it supports it, but I love it for the basic day-to-day tasks that I do 100's of times a week.
And agreed on Sourcetree. It started out promising, but oof. Not any more.
I use the terminal for everything else. I would never trust a GUI to do a rebase, not even sure if it's possible with Fork because I've never tried.
UIs can be nicer though for rewriting / making finer-grained splits than the hunks that -p decides on, definitely agreed there. I have broken out a UI just to simplify staging some gnarly commits. GUIs are also often nicer for understanding and resolving nasty three-way merge conflicts.
distributed VCS is neat and all, but the vast, vast majority of cases have a canonical source-of-truth repo somewhere, and the rest are effectively just private mirrors. for those cases, distributed is mostly a significant source of complexity rather than capability. though it is significant to have an "escape hatch" when you need it.
I repeatedly run into this using the interactive features.
but for me a bigger reason to prefer a git UI is that I can actually see the graph. I can do things like drag branches between commit nodes. I find this so much easier and safer than the cli
VSCode’s GUI handles most of what I use -p for, though if I need to use `s` inside -p I drop to the integrated terminal. Not sure if the gui has an equivalent but I haven’t noticed it.
Stash on the other hand isn’t missing anything I care about: the gui lets you name stashes if you want, apply latest, etc…
I cannot imagine using git and only being able to push entire files...
-
And for the record, I use Sublime Merge and it does a great job mapping to terminal commands.
Hover over any button and you get the exact git command it will run. It doesn't mess with your tree directly, every action maps to a normal human readable git command.
If you want to make a stash with untracked files for example, you just hit the arrow next to "Stash" and get a dropdown with command line args and descriptions for what they do. Sublime Merge will then run it with the exact args you entered, show you the exact CLI command it used, and will show you the exact output.
For me Sublime Merge is strictly better than a terminal. I'm comfortable with terminal commands but it's the terminal with a very nice diff view, clean graphs, easier text editing, etc. I never have any ambiguity about what it's going to do.
I like it better than git's built-in `-p` because you don't have to rely on git chunking things up the way you hoped, or spend time splitting git's chunks (hunks?) to get the specific line you wanted to stage.
The git CLI is workable for a lot of things,but the experience of higlighting an arbitrary block of text and saying "commit THIS" has not been matched in any other git UI. We're not talking about hunks or lines here, but literally committing an abitrary range of characters.
Honest question: what is the practical use case for this? I'm a fan of small, atomic commits but I don't recall ever wanting to commit just a range of characters.
I can stage hunks by yanking the diff header (excluding the line that starts with @@) and pasting it above the hunk I want to stage and then filtering the hunk through:
:'<,'> !git apply --cached -
If I want to unstage it, I can press u to restore the hunk I just filtered and then run :'<,'> !git apply -R --cached -
I can commit from within vim by reading the verbose status output by running: :r !git status -v
typing my commit message at the top and filtering it through :'<,'> !git commit -F -
> Does any GUI offer `-p` in `git commit` and `git stash`? I literally use it 10s times per day, can't live without it once I started using it.In addition to what I wrote above using git apply --cached, I can actually edit hunks from within vim and then filter the hunk (with the diff header) through the recountdiff utility that comes with patchutils. That basically updates the numbers in the line that starts with @@ to account for the changes in the number of added and removed lines introduced by the edit. This way, I can stage my changes and still exclude extraneous changes or debug statements I've added to the code.
I've actually found this to be a better experience compared to using the -p option.
if you know the bare basics of emacs(like a few file commands and how to exit), magit and vim that is a huge productivity win. magit is simply the finest complete git gui that does most things seamlessly.
simple workflow
in the project dir
$ emacs
spc-g-g to enter magit
? shows help(and every command pops up a menu with options)
j/k to navigate lines up and down
s and u to stage and unstage chunks of text/files/lines
x to delete something
cc to initiate a commit
edit the commit message
ctrl-c ctrl-c commit.
ctrl-c ctrl-c abort commit
q or escape goes back a "page" like from viewing the log to go back to the staging area
the trick is everything follows that basic form where [a-zA-Z] starts a command, pops up a menu and shows the next options but the general trend is that it usually is the same two letters. bb is checkout a branch and it usually pre-populates the thing you are on if that is applicable. ll is log this branch. la is log all branches and everything in the log is interactive.
it's pretty magical.
doesn't work well with vim plugins... need to go to insert mode to actually interact with it (might be configurable and fixable)
stuff that takes one keystroke on magit is clunkier in gitsavvy. tab in magit expands short diffs from the main status page where you can stage or unstage selections or get an overview of the changes. l to "inline diff" opens a diff in a new file whereas tab just opens and closes sections on the main dashboard. ctrl-jk move from chunk to chunk. enter opens the file to edit or more generally does an action like view the commit under the cursor if you are in a the log graph and q will "quit" out and pop the interaction back to the log graph.
it's hard to overstate just how well everything flows in magit and i've never heard anyone say anything bad about it other than something like I wish it wasn't tied to emacs. simply the best and most well thought out piece of software i've used.
edit: i'm just scratching the surface on what magit can do... literally everything is possible through the interface even one off git commands but almost everything is very easy and interactive from any point in the interface
There's also hub, from GitHub. I find myself using "hub sync" to update all my local branches at once.
A unicycle can also be better than a car. Doesn't mean anyone should ever choose a unicycle over a car (unless you're a clown I guess)
> I just can't get cozy with doing a lot of heavy lifting in any shell environment
I've argued that undergrads should spend their first year (or first semester) almost exclusively on the terminal/in the shell. Sure it makes some operations cumbersome but after you get over the learning curve the returns are spectacular.
The command line isn't some mystical scary thing, it's a extremely effective method of controlling a computer. It's survived this long for a reason, and it's not going to go anywhere. It's powerful, and extremely simple. Children learn how to use it every day (nerdy children, but still).
Try spending a few hours over the weekend actually trying to learn it. If you do, you'll see how it's a lot easier than you thought, and saying that you're "terrified" of it is silly.
For some things, definitely not for doing a 3 way merge.
synced = pull origin master --rebase. # Update myself with master
squash = rebase -i origin/master # Let me optionally squash whatever has happened since master
publish = push origin HEAD --force-with-lease # Save to orig in (github)
pub = push origin HEAD --force-with-lease # Save to origin (github)
ammend = commit --amend # I cannot spell this word for the life of me
amend = commit --amendgcmsg "git commit -m" - Git commit message
gco "git checkout" - Change branch
gd "git diff" - Files differences in staging
gl "git pull" - Pull from remote
gp "git push" - Push to remote
--- Tool looks interesting!
A must read for every cli git user.
[0] https://github.com/epage/git-stack/blob/main/docs/reference....
[pull] rebase = true # if you're going to do it anyway might as well make it the default
[rebase] autoSquash = true # if you use --fixup commits autoStash = true # save yourself the roundtrip
This reminds me of one of my favorite silly aliases, which requires declarations in both my shell profile and my .gitconfig:
In .bashrc : `alias gits=git`
In .gitconfig : `[alias]` `tatus = status`
This allows me to mistype `git status` as `gits tatus` and brings me a small amount of joy.
I wonder if anyone has gone from lazygit to magit or the other way around. As someone who uses emacs for my day to day dev work I can't see myself changing.
Error! Your Xcode (13.0) is too outdated
I don't have the luxury of upgrading yet. This requirement seems overly fussy and opinionated.It's hostile for devs to push PPAs only, as it implies that their ability to push updates faster is more important than the distro's review process.
Distros (Debian in particular comes to mind) have some really annoying packaging rules, and as a maintainer of a Go program, it's a huge pain, so we decided to just set up a repo with https://cloudsmith.com/ instead of trying to deal with that. They require every dependency (indirect or not) to be packaged separately. We don't have the time for that. Way simpler to just build a static binary and ship it.
Our GitHub is set to delete a branch whenever we squash merge it in a PR. But for the life of me I cannot get my local version to cleanup too. All the stack overflow popular answers that use sed and such fail for some reason.
Thank you! Didn't know about it and it solves the problem I'm having.
panic: '%' is not recognized as an internal or external command, operable program or batch file.
goroutine 39 [running]:
github.com/jesseduffield/lazygit/pkg/commands.(*BranchListBuilder).obtainBranches(0xc00039bef0, 0x1367340, 0x10000, 0x0)
/home/runner/work/lazygit/lazygit/pkg/commands/loading_branches.go:43 +0x693
github.com/jesseduffield/lazygit/pkg/commands.(*BranchListBuilder).Build(0xc0000dbef0, 0x11315f7, 0xc0000a4690, 0x1326e87)
/home/runner/work/lazygit/lazygit/pkg/commands/loading_branches.go:103 +0x52
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).refreshBranches(0xc0000b8000)
/home/runner/work/lazygit/lazygit/pkg/gui/branches_panel.go:69 +0xc6
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).refreshReflogCommitsConsideringStartup.func1()
/home/runner/work/lazygit/lazygit/pkg/gui/commits_panel.go:69 +0x45
github.com/jesseduffield/lazygit/pkg/utils.Safe.func1(0xb35af5, 0xc000055da0)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:95 +0x2b
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0xc00039bfb8, 0x0, 0x0)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:106 +0x67
github.com/jesseduffield/lazygit/pkg/utils.Safe(0xc00008aa40)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:95 +0x50
created by github.com/jesseduffield/lazygit/pkg/gui.(*Gui).refreshReflogCommitsConsideringStartup
/home/runner/work/lazygit/lazygit/pkg/gui/commits_panel.go:67 +0xa9
Before the crash, the UI is drawn reaaaaallyyy slowly (my cmd window is 170 characters wide -- maybe that's why)In any case, I prefer to stick with the command-line.
For me, it feels really similar to "gitx", which was mac only and stopped being maintained. Having it just be in my terminal is a bonus.
One suggestion: Use PgUp and Pgdown to scroll a screenful, and use arrow keys to scroll one or two lines. Use shift with some keys to scroll half screens.
Is there a keyboard shortcut to go into remotes or tags panes?
Protip: alias lg="lazygit"
It's a port of xtree gold that works on modern windows. I've been using it daily for probably a decade.
It seems to me to be a solution in search of a problem.
It looks to be nice but it merely adds an extra level of complexity.
Going to install this tonight, does it work well with LFS?