I don't know why so many devs avoid a GUI for Git
twitter.com
twitter.com
There are many reasons why the CLI is far more efficient for me for this.
1. I’m rarely ever just doing GIT operations in isolation. Depending on the kind of project there’s a whole lot of other stuff going on as well…builds, unit tests, etc… I can’t run that out of Git Tower. But I can run all of those from within the same CLI environment.
2. I can never modify the way GIT tower presents information to me. However, I have a lot of tools to isolate exactly the information I want using git on the CLI where it makes sense because the CLI allows me to compose GIT outputs with an extremely large library of tools in a way no GUI application does.
3. I love scripting. If I do the same action more than a few times I will write a script for it. And the CLI allows me to do that in a way GUI tools don’t.
I can click a file I want to review faster and easier than I can type the name, and Git Cola's diffs are easier to read than default black and white CLI diffs.
I've likely just backgrounded or closed some other reference to the file: 'vim', 'pylint', etc.
The shell makes subsequent references basically free with this: '$_'
I've internalized this as "the last arg to the last thing I ran". It probably has some esoteric meaning to BASH...
Point being: if one plans the placement of their args they stop having to think about finding files or tabbing to exhaustion.
This works with anything you'd give as an argument
Complicated options are really the only thing I'd consider faster in the CLI, simply because they don't exist in most GUIs.
E.g.:
- Stage/unstage a file in one click.
- Stage/unstage/revert a line or block with select+hotkey.
- Switch between editor and (editable) diff with one hotkey, and another to toggle between inline and side-by-side view.
- Focus the commit message box with hotkey, type message, ctrl+enter to commit.
- Hotkey or command palette to switch branch, then search for branch name.
- Blame for current line always visible.
- Commit list, file history, or line history can be focused with a single command from the palette (or hotkey if I could be bothered memorising it).
- Easily view stashes and apply all or part of them in a couple of clicks.
- Open any git ref in a new vscode window (not editable), without needing a separate checkout or modifying the current one.
- Easily view commits on other branches and cherry pick/merge/rebase at will.
A magic var: "$_"
I made another post in this thread about it... I'm tired/on mobile, so apologies if I'm terse.
tldr: get in the habit of arranging the file to be the last argument. Subsequent use is entirely free
Or, really, anything you want to pass around. Not just files.
Seems more suited for smaller projects than larger ones, usually I'm always jumping between HTML template, server code, JS, browser, and some badly documented library I suspect is buggy.
I don't often do multiple different things in a row to one file, but for those times I do this will probably double or triple my speed.
Thanks for making us all aware of it!
This sequence is more regular with multiplexed terminals - one window, many panes.
Many people like 'tmux'. I ended up stuck with my terminal handling it (Kitty)... I learned this way first.
Anyway, if I'm iterating a lot on something, I end up using two or three panes at least.
One pane as the ringer/wildcard while others are more static - an editor, the interpreter, etc.
Reserving the 'ringer' pane protects that last argument for quick use. This reservation is aided by having the other static panes for my editor and such
As soon as the mouse cursor or having to scan my eyes across the screen is involved in any way I'm being forced to waste more time looking at less information. The fatigue of using GUIs adds up tremendously in the course of a day. I suspect the people who prefer them aren't aware of this. There's likely a negative health correlation with GUIs (eye strain, back problems, etc).
I also recommend against using git GUI for beginners just because it hides so much of what's going on, making it easy for people to stop learning after they figure out how to do exactly 2 things with it: commit and push.
But honestly if we're going for "best" I think magit is the winner.
Also, the mouse will generally beat the keyboard for selection tasks, which is a decent amount of git usage. Splitting up changes in your working directory into multiple commits is substantially faster with a GUI, as well as a lot of commit graph manipulation options.
A couple other things the CLI sucks at:
- Complicated staging of chunks of files - Complicated interactive rebase
For some operations it's more that one command, so you are present with more than one dialog.
For me it's not just a convenience, but a learning tool about more obscure Git operations and their parameters. Several times when I found the documentation obscure I would just make Git Extensions generate a command, and it helped me to understand a command -- or discover one.
Having said that, I find Git command-line interface hard to memorize and not very consistent/logical, so I prefer to use the GUI when possible. And you cannot beat it for partial commits or resets.
"Blue is the best color" is a preference. I am perfectly entitled to say "Nope, in my view, Red is the best color" without justifying. I just like red better.
I like minimalism, and a CLI tool is always more minimal than a GUI one. Also I like doing stuff with my keyboard, and the CLI is perfect for that. GUI tools usually require a mouse, and that is not ergonomic for me (but ergonomic is personal, again).
It can’t just be any UI though, that I’m particular about. My favorite used to be the native GitHub client for Mac, but when GitHub abandoned that and replaced it with a much worse cross platform app I switched to Fork[0] which has been excellent and even has a native Windows counterpart. Sublime Merge[1] is also nice but doesn’t gel as well with how I think.
[0]: https://git-fork.com/ [1]: https://www.sublimemerge.com/
gitk takes similar arguments as “git log” or “git rev-list” does. It’s a pretty ok way to view commit history.
Both of these are kinda quirky tk/tcl programs. But they are available on cross platform, so I only have to learn one GUI for Linux, Windows, and macOS (though the macOS support is the most likely to be broken).
0. Visually demonstrate proposed intended behavior unfamiliar to the user.
1. Visually select desired operation behavior interactively.
2. Gradual disclose features and teach a cli from a gui tool.
A good git gui should continually display cli equivalents, log cli-equivalents of operations performed, or allow visual commits, rebases, cherrypicks, merges, branches, etc.
I kind of have the opposite question - what benefit does a GUI have for git? If your tree gets super complex I get how a GUI makes it easier to navigate, but if you only have a couple branches it seems easy enough to just view in terminal.
Still, for every other git function I find the cli and ctrl-r much quicker.
I've paired with devs that use CLI and it feels like they're in the stone age, especially when doing merge operations, but, at the end of the day, to each his own.
It almost seems like, i have a model of git in my head and these GUIs have another model in mind. And it does not match.
I usually still make commits from the command line, but then review them in SourceTree before pushing. I also find it to be a much more straightforward interface for doing an interactive rebase.
Looking for a replacement has been on my to-do list for a while however, as Atlassian has kinda been letting it lagnuish.
I’m not affiliated with them, just a satisfied customer.
[1] https://fork.dev
git-cola[2] is a decent stand-in for TG's commit review window though.
Also, a HumanScale 6G 500 keyboard tray because few tables are ever at the correct height.