TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

GUM: A better CLI for Git

305 pointsby edaveover 13 years ago

28 comments

acabalover 13 years ago
This is such a great idea. I'm using Git for my own repositories and I find myself doing searches for things like "how to undo a stage" or "how to revert a file" so often that it almost takes as much time to use Git as it does to do my programming.<p>No doubt Git gods who have every nuance of the system memorized can take advantage of the flexibility of the (IMHO) complicated and obtuse CLI. But for schmucks like me who just want to get work done and not worry about it, something like this would be a godsend.<p>I've more than once thought about switching away from Git just because I'm scared I'll do the wrong command and mess something up--and I've been programming for 15 years.
评论 #3530450 未加载
评论 #3530356 未加载
评论 #3533151 未加载
enobrevover 13 years ago
This is probably going to be a fairly unpopular opinion, since it seems git has won the popularity contest, but this is why I've always preferred bzr. Sure, it's a bit slower, but the interface is consistent. There aren't as many commands and they generally do the same thing every time. There aren't many switches on those commands either, besides the necessities, like defining revision numbers to apply the commands to.<p>I started using git about 6 months ago, primarily for github, and it's obviously a very powerful tool. Unfortunately, all that time that is generally saved by git's speed gets sunk into browsing around trying to understand how to use it. I have about 15 git projects right now and I still have no idea how to do some of the simplest things with git.<p>Maybe it's just because I came from years of svn, but I pretty much had bzr's interface figured out within a week. That whole week, I searched around for commands and whatnot and since then, it's been Incredibly rare for me to wonder what commands do what.<p>I'm not saying you should switch, as git is certainly an incredible tool. But if you live your life in the CLI, I would recommend trying bzr out. The simple interface is a dream in comparison.<p>Personally, if it weren't for github, I probably wouldn't use git at all for my own projects. That said, I may end up switching to git Because of github. And that's pretty much the only reason. Git's won the popularity contest an hence has a far larger ecosystem. But if I do make that switch, and that's a huge "if", I would miss bzr's CLI about as much as I miss childhood.
评论 #3532935 未加载
评论 #3532411 未加载
eridiusover 13 years ago
Most of this stuff can be done with aliases.<p>git stage<p><pre><code> git config alias.stage '!f () { if (( $# &#62; 0 )); then git add -- "$@"; else git add -u; fi }; f' </code></pre> git unstage<p><pre><code> git config alias.unstage 'reset --' </code></pre> git undo is too ill-defind to actually implement. Sounds like the author wants it to be `git reset --hard HEAD`, but it's far more dangerous doing that while termed `git undo` than it is while termed `git reset --hard HEAD`, because people will have unrealistic expectations of what it does.<p>What's wrong with `git rm`? Here's a hint: you don't need to use it. Most people I know just delete the files however they want, and then run something like `git add -u` to pick up the deletions. That's exactly what the author is suggesting, but that's what people do today, so I don't see the issue.<p>As for git status, there's already a --short (or -s) flag that gives a very terse output. I personally use that all the time with an alias `git config alias.st 'status -sb'`.<p>Automatic setup? Put that info in the global config file. If git had to prompt for it, it would naturally place that info in the per-repo config file (absolutely would not make sense to automatically modify the global one), and it would be more confusing to users to be constantly re-prompted for name/email (because they switched repos). I don't see the problem with just telling new users to set up name/email globally, which every git tutorial I've seen does.<p>git switch<p><pre><code> git config alias.switch checkout </code></pre> For git diff confusion, just use aliases for different commands. Do not make me type STAGE, that's no friendlier to users. I personally run with the following two aliases:<p><pre><code> git config alias.staged 'diff --cached' git config alias.unstaged 'diff' </code></pre> though I rarely use the `git unstaged` command. I also have<p><pre><code> git config alias.both 'diff HEAD' </code></pre> though I never use this one. Perhaps other names can be chosen that the author likes better.<p>The bit about deleting branches is misguided. `git remote` is a command that has sub-commands. `git branch` isn't. I understand that the author thinks having two styles of commands is weird, but there's not really a good alternative. Commands like `git remote` that have sub-commands would not work very well at all in the switch model (for a pathalogical example try to imagine what `git svn` would look like this way), and switch-based commands, which is most commands in git (and most commands in UNIX in general) would not do well in the sub-command model.
评论 #3530455 未加载
评论 #3530435 未加载
blumentopfover 13 years ago
Why this is needed:<p>Latest blog article over at progit.org: "Reset demystified" <a href="http://progit.org/2011/07/11/reset.html" rel="nofollow">http://progit.org/2011/07/11/reset.html</a><p>Scott Chacon, author of the the Pro Git book, admits there that he didn't cover the "reset" command in depth in the book because he didn't fully understand it. Go figure...
Groxxover 13 years ago
I quite like the idea, primarily because it would keep actions 'sounding like' what they affect. stage and unstage being the primary examples. Yeah, 'add' and 'reset' work, and fit other semantics, but when everything else refers to something you've added as something you've staged? Unnecessary cognitive friction. Add is largely useful for migrating from CVS/SVN/etc, but why not both with some porcelains?<p>That said, take the time and learn what git <i>does</i> and how it works and it makes a <i>ton</i> of sense. It's remarkably simple, and then the commands map directly to what you're doing to your history, which is utterly fantastic.
davvidover 13 years ago
While this may be a nice idea, I don't know if it improves the situation. Improving the situation means tackling the entire problem, top-to-bottom.<p><a href="http://thread.gmane.org/gmane.comp.version-control.git/185825/focus=185863" rel="nofollow">http://thread.gmane.org/gmane.comp.version-control.git/18582...</a><p><a href="http://thread.gmane.org/gmane.comp.version-control.git/175061" rel="nofollow">http://thread.gmane.org/gmane.comp.version-control.git/17506...</a><p>Quoting Junio, the git maintainer:<p>"""Rc or not rc, just repeating a fuzzy and uncooked "idea" around phoney ref-looking names that will end up confusing the users, and selling that as if it is a logical conclusion to "we want to give an easier to understand UI", without presenting a solid user experience design that is convincing enough that the "idea" will reduce confusion will not get us anywhere"""<p>Here's the first example from the blog post:<p><pre><code> # Why not replace things like: git reset HEAD -- file with: &#62; git unstage </code></pre> What the author fails to realize is that you could have just said, "git reset file", which makes this `unstage` example much less convincing.<p>We actually do not recommend `git reset --hard` very often these days. `git checkout -f` is nicer alternative and is semantically related to `git checkout file`.<p>The 'stage' alias that adds and also understands deletions is a nice addition. It can be implemented as an alias. `git config --global alias.stage 'add -u --'`.
评论 #3531087 未加载
alwillisover 13 years ago
Such a good idea. I mostly use Mercurial, which has a clean, logical and consistent CLI which I like a lot. And while I like the <i>concept</i> of Git, using it makes my head hurt.<p>I'm reminded of the article that compares the two: Git is Wesley Snipes; Mercurial is Denzel Washington: <a href="http://www.ericsink.com/entries/hg_denzel.html" rel="nofollow">http://www.ericsink.com/entries/hg_denzel.html</a>.
skrebbelover 13 years ago
I expected much more from this, off the title.<p>Look, Git is a major pain in the ass because it's designed to support every possibly imaginable workflow. The only way to do this is to just expose Git's internals, i.e. make users think like Git, instead of making Git think like its users. This fits the minds of kernel hackers perfectly (they think like computers do all the time), so there's your history-of-Git in a one-liner as a free bonus.<p>The only way to make Git more usable is to make a frontend that carefully and in a well thought out way enforces a certain workflow. It'll be more usable for people who use that workflow, then (and, obviously, less usable once you want to step outside that workflow)<p>git-flow [1] is a nice example of this. I'd love to see more examples for additional workflows. I'm also very curious whether it's possible to do this without leaky abstractions, i.e. to really have a team up and running that doesn't understand anything about Git, and only understands the workflow. Did anyone using git flow manage that? (i.e. have devs never touch 'bare' git)<p>[1][<a href="http://nvie.com/posts/a-successful-git-branching-model/" rel="nofollow">http://nvie.com/posts/a-successful-git-branching-model/</a>]
chocolateboyover 13 years ago
This already exists. It's called EasyGit:<p><a href="http://people.gnome.org/~newren/eg/" rel="nofollow">http://people.gnome.org/~newren/eg/</a>
评论 #3530902 未加载
评论 #3530611 未加载
评论 #3532304 未加载
beggiover 13 years ago
This is pretty nice. I totally concur with the post, and I think logical commands is the biggest (only?) benefit of Mercurial over Git... been using Legit by Kenneth Reitz lately... I recommend it highly <a href="https://github.com/kennethreitz/legit" rel="nofollow">https://github.com/kennethreitz/legit</a>
dave_sullivanover 13 years ago
I've seen a few "better CLI for X" applications lately, I think there might be something there. Personally, I almost prefer cli at this point for lots of stuff, but a lot of it is still just so cryptic. It doesn't need to be.<p>Thinking about usability doesn't have to be limited to web apps, and it's refreshing to see some people starting to agree.<p>Edit: definitely not sure where a business would be for a product like that, such a niche market, and a market that doesn't like paying for things. But who knows?
moeover 13 years ago
I think "git undo" would be even nicer if it was a generic undo and simply undid the last operation (only when possible of course; unpush might be slightly problematic).<p>Also I'm really tired of messing with ~/.gitmodules and unwieldy *submodule-commands that demand to be executed in the project-root all the time. Why can't we simply "git add" sub-repositories, perhaps bailing with a warning by default and an extra-flag to really do it...
评论 #3532595 未加载
zmanjiover 13 years ago
Is it possible for all of these to be implemented as git command aliases?
评论 #3530326 未加载
DrCatboxover 13 years ago
Where is this GUM or better cli for git? All I see is a README file containing the same thing as the webpost. Not to be a complainer, but there may be a reason the commands are the way they are and you cant simply change them without changing the implementation, perhaps you should look at alias to solve your memory problems.
评论 #3530338 未加载
matthewsnyderover 13 years ago
.gitconfig is your friend: <a href="https://gist.github.com/1706237" rel="nofollow">https://gist.github.com/1706237</a>
评论 #3530472 未加载
akkartikover 13 years ago
I recently discovered that creating a script called git_command somewhere in your path makes this work:<p><pre><code> $ git command </code></pre> Now these recommendations are easy to implement.
评论 #3544082 未加载
jmccaffreyover 13 years ago
I'm not sure I agree that it's necessarily bad if the interface is a side-effect of the implementation. It seems very worse-is-better to me.<p>I feel like when the interface is a side-effect of implementation, you get a more gradual sliding scale from user to developer (like being able to experiment with web apis by curling at them).<p>In git's case, I appreciate that I can trawl around through my .git directory and not get lost because it pretty closely matches the interface.
评论 #3530936 未加载
phzbOxover 13 years ago
One problem of that thought it that it will make git commands even more obscure. I.e. when a user will have to use the real git cli, they will be totally lost. I'm not saying it's a bad idea, just something to think about when designing the new cli. Maybe try to stay consistent with the commands while still making them easier to remember and understand. For instance:<p><pre><code> git diff STAGE HEAD </code></pre> seems a bit unconventional to me.
jsmcgdover 13 years ago
Can I suggest that 'select' is used instead of 'stage'? After all, one is just selecting the files to be committed. Staging, although a legitimate use of the word, is a bit abstract I feel. I can't imagine anyone failing to understand the concept of selecting something.
freshlogover 13 years ago
Make this even more intuitive by wrapping git (or gum) in a REPL:<p><a href="https://github.com/defunkt/repl" rel="nofollow">https://github.com/defunkt/repl</a><p>I use this on a daily basis to avoid having to type "git" repetitively.
reinhardtover 13 years ago
Cool, I might try this to give Git a second chance, for now I am resorting to hg-git whenever I have to touch a git project. Sometimes it gets confused when I'm rewriting history on the hg side and pull from the git upstream but overall having a sane UI I feel confident about without googling before every command (or worse, limiting myself to a "safe" subset and using it almost like Subversion, as some of my coworkers) outweighs the occasional snafu.
评论 #3531138 未加载
pjscottover 13 years ago
This is similar to what I get with magit-mode in emacs. It's pretty slick.<p><a href="http://philjackson.github.com/magit/" rel="nofollow">http://philjackson.github.com/magit/</a>
评论 #3531868 未加载
评论 #3531762 未加载
DannoHungover 13 years ago
All I want for git is a "git motd" command that teaches you a little bit of the plumbing every time you run it.<p>And I will set it to execute when I login on a shell.
bryanpover 13 years ago
I've noticed that making the mental switch from writing code to committing it costs quite of bit of time throughout a day of development. A more intuitive interface would remove the need to make the mental switch. This interface feels much more intuitive to me -- great job.
cleverjakeover 13 years ago
There is no code on github<p><a href="https://github.com/saintsjd/gum" rel="nofollow">https://github.com/saintsjd/gum</a><p>but the idea sounds great!
评论 #3530493 未加载
meemoover 13 years ago
I like the instructions in git status. I usually follow them when I'm not sure of what to do.
ww520over 13 years ago
git status usually has a help command to unstage the change.
alinajafover 13 years ago
I'm going to put my grumpy old man hat on for a second and say that if you don't understand how git works, then you shouldn't be using it. Go use svn or hg or something that has a simpler internal model, and good luck to you.<p>For me, gits internal model is simply not that hard, and I'm a run of the mill twenty-something year old developer who feels vaguely guilty about not knowing how fundamental data structures and algorithms work. It's a directed acyclic graph that points to items in a content addressable database. Between the progit book and the man pages, I had a pretty good conceptual model of it in an afternoon. I encourage anyone who actually wants to learn it to spend a little time with TFM and get it out of the way.<p>Otherwise, seriously, quit your whining. The CLI makes intuitive sense to me and I can manipulate the DAG without much mental effort. The worst case scenario is that you rebase public history, and `git help rebase` will tell you how to get yourself out of that mess.
评论 #3530917 未加载
评论 #3532572 未加载