551 points · by jesseduffield · 8y ago · 229 comments
I'm not. Are there many people that are? Is this not just a matter of learning to use shell keybindings effectively? That and aliases does wonders to avoid repetitive typing. Many times I type `git s` (alias for `git status -s`) out of reflex when I really meant to do `ls`.
When I forget to add `-a` to `git ci -m ...` (`ci` being `commit`) and get an error because the index is empty, I just `<caps>kF-aa<enter>` (<caps> being <esc>) to add it and re-execute. It's muscle memory; I do it before I even realize I did it.
Every time I hear people saying how much they prefer the git command line is because they never seriously tried to leverage the git features of their IDE.
Vs code with git lens or intellij idea have excellent git integration. Everything is one shortcut away. The git commands that are used are log into a console if you want to check.
At the end of the day both methods work, it's just a matter of preference but it is worth trying a good git UI.
Also if you ever try to teach someone git, it's not as intuitive as you think [1]. Having a consistent UX can help.
That's why there is definitely a space for this kind of git UI as presented in the article. [1]http://stevelosh.com/blog/2013/04/git-koans/
I prefer sticking to the Unix way. An editor is an editor. Why should it support git specifically? Git is only tangentially related to file editing, so it doesn't really make sense for an editor to know anything specifically about it.
> Every time I hear people saying how much they prefer the git command line is because they never seriously tried to leverage the git features of their IDE.
But I am! The whole OS is my IDE.
Seriously though, I've done fugitive in vim and magit in emacs. After some time of using them almost exclusively, I've decided it's better to use the shell. It's not because I haven't tried more "integrated" ways of programming, but because I find that the flexibility/power that comes with treating every feature of an IDE as a separate program in an OS environment is better.
EDIT: Added more comments.
Because it's convenient. IDEs work with files. Git manages files. Ergo, IDEs should support Git.
I agree with this. Strongly.
That's similar to saying "a smart phone is a smartphone" why not have one device to take calls, and another to store contacts, another to browse the web, another to listen to music. It's ergonomics.
Many things are more efficient when integrated.
I do agree that git could certainly do with a more consistent command line interface - but I imagine that won’t even be considered until that next major version of git, if it ever arrives.
I have used IDEs but I still prefer the CLI client.
Like with most things in IT, GUIs are great for simple things but the CLI is more expressive and exposes more options. Then once you've spent enough time using the CLI tools it's sometimes more jarring to switch between the GUI and CLI than it is to just use the CLI for simple tasks that could easily be done in the GUI.
Same with vim. Too many options. Poor UX. Eg. Why are there two way to scroll down? Just use ctrl-d which helps you retain the context of the code you’re navigating.
I think this statement is much more powerful in reverse. People who prefer the git features of their IDE have probably never seriously tried to leverage the features of git...
I prefer the git command line. It supports every single feature of git, and as an interface it’s completely and totally frictionless.
People trying to create tools and UX around git usually do so under the false impression that git is the source of friction, when really they are.
> Also if you ever try to teach someone git, it's not as intuitive as you think [1]. Having a consistent UX can help.
Are there people who need this kind of help learning, but then go on to do well at it?
I’ve found programming in general is extremely binary. Either you’re the kind of person that can grasp it and has the motivation to track down answers yourself and hack away, or you aren’t.
Being able to pick up a new system or technology and understand it very quickly is what it means to be a programmer, even more so than the act of programming itself in my opinion. I think trying to find shortcuts around that to teach people is a bit of a catch-22.
Not as part of the same operation, but the usual workflow is that there's a pane in the somewhere that lists all modified and staged files, and you can click on those to see diffs (or just click "commit" if you don't care).
But any action I want to be made on the repository, I do it myself.
I have some exceptions though, like if I want to revert the hunk I have the cursor on it's nice to be able to revert (or even stage, but I still use `git add --patch` for that) it with one shortcut.
I find all the colors and ques distracting while I am coding.
Unless you're on someone else's machine. Then you'll still need the cli.
IMHO, that's commendable.
I use aliases too but I also use SourceTree (gasp) for bigger commits. It's not even that I don't know how to git add -p, but clicking "add this hunk" is way easier to do.
Version control functions should be available right in your editor (e.g. magit) and you can't really beat one character hotkeys for version control stuff. It doesn't get more convenient than that.
That sounds like limiting the functionality of the whole computer to what the text editor can do. That doesn't make sense. Next, you'll want to browse the web from the editor because you don't want to leave it (just because emacs does it doesn't mean it isn't absurd).
Anyway, I think it's better to configure the system so using multiple programs is as quick and effortless as possible. For your example, I use i3, a tiling window manager, and have the screen split with a terminal window on the left and my editor on the right. If I wanted to check `git status`, I just type `<super+h>git s<enter>`. To go back to the editor, `<super+l>`. There's really not much difference with a single character shortcut.
Well, you're clearly replying to an emacs user. He/she will not find that statement the least hyperbolic.
Not really. It's about putting the most frequent features into your editor, so they can be accessed effortlessly. If you have to do something which is less frequent and the editor does not support it then you still have the terminal.
> If I wanted to check `git status`, I just type `<super+h>git s<enter>`. To go back to the editor, `<super+l>`. There's really not much difference with a single character shortcut.
It's efficient compared to switching to the terminal with alt-tab or something, though by single shortcut I meant that you can use it right in your editor buffer, so it's really just pressing one or two keys vs. `<super+h>git s<enter>`
I can diagnose and fix issues for people in around 5 minutes leaving them with history that works everywhere and I don't need to jump to my workstation for reference on aliases.
Thankfully, people I work with seem to like git, except for the odd git push --force breaking branches for them.
That reminds me that I'll have to teach one QA to do rebases. His merges break our history graph in funny ways.
'y' (yank) = git pull
's' (shove) = git push
'g' (give) = git commit -am x
'o' (open) = git checkout x
'p' (pick up) = git branch x
'l' (look at) = git status
^rstat -> git status
^rcomm -> git commit
^rkout -> git checkout -d foo
^redit -> git commit --amend --no-edit
^rdeco -> git commit --oneline --decorate
I know it's popular, but I think I'd find it confusing for completely separate commands to relate like that. It's like cups; I was really surprised to find that the shell command `cancel` was about print jobs. I'd thought it be something more generic. I like it that git keeps all these functions related as subcommands. Makes things more readable. `git status` is not general system status, it's git's status.
I also had even shorter shell aliases like gl, but abandoned that. I'm switching shells to often and their configs are constantly out of sync which confuses more than it helps.
# x| = cursor is in insert mode, after char 'x'
# |x| = cursor is in command mode, on char 'x'
# (<keys>) = keystrokes entered resulting in prompt on next line
$ git ci -m "<str>"| (<CR>)
$ | (<Esc>k) # puts shell prompt into command mode (<Esc>) and cycles upwards to previous command (k)
$ git ci -m "<str>|"| (F-) # from current position, reverse search (F) and stop on first occurence of '-'
$ git ci |-|m "<str>" (aa) # cursor is on '-' char, append (a) 'a', i.e. transition into insert mode by advancing cursor after current char, then insert 'a' literally
$ git ci -a|m "<str>" (<CR>) # execute command
$ |,gcm for git commit -m ""
,ga for git add -p
,gl for git lg
and similar.
That said, I rarely use the terminal for git these days, Magit is just so much better.
Personally I use tig, which is basically this but different. I used to use Sourcetree and I loved it but it slowed to a crawl with bigger projects with long histories.
Best screenshots I can find on google are ironically from the Atlassian blog:
It's easier to see it in action than explain it. If you've two minutes to spare, check out this emacsrocks screencast [2], or Howard Abram's longer presentation from the PDX Emacs Hackers meetup [3].
[1]: https://magit.vc/
> Optionally, start annotating from the given revision.
If you use it daily don't forget to donate to the developer at least once, sprinkle some of that full-time corporate cog money on them.
From what I gather it's nowhere near as feature-complete, but it lets me create commits with immense ease and precision.
Now I have all the power of vim’s modal editing with Emacs’ vastly superior ecosystem of packages.
What you should have done is use magit and looked into the emacs version of vim: https://github.com/emacs-evil/evil
But the real power is integration with the rest of emacs/being written in elisp. If I want to change or script behaviour, I have easy access to all the internals, and I can integrate it with other parts of my emacs workflow. For example, I can use magit to view the diff of a coworker’s PR, easily capture snippets, including links to their location in our internal BitBucket instance, into an org buffer, and then write up and send an HTML formatted message with my comments, syntax highlighting, etc to my colleagues with my feedback.
Similarly, my TODO list is managed by org, and I can have links to commits or files at a certain commit directly in my agenda or notes and jump to them.
This is all within my editor, with all the text editing, code navigating, and linting capabilities it provides!
It's the same thing with vim for that matter. A basic-ish text editor setup is trivial in both editors but beyond that things start to fall apart. Plugins/modes rely on being run in *nix environments to work well, and the workarounds for Windows are never 100%. The startup times start to suffer a lot too in vim and Emacs when you pile on a lot of features.
I think that's why VSCode has gained so much traction. For coding it's got easily 90% of the same features as both vim and Emacs (if not more), but it's trivial to set up and with many users being on Windows pretty much everything has first-class Windows support.
So that's what happens every time. I stick to VSCode and keep a lightweight vim setup around for quick text edits since it opens instantly. Perfect for quickly changing a config file or jotting something down if I don't have VSCode open.
lol
Let me repeat that.
Your ticketing system is Turing-complete. I don't remember where I heard this first, but someone at my company (at least supposedly) proved it once.
Jira has managed to grow into such a bloated, complex, incredibly pointless piece of software that I've never met someone who likes it. It's like software design by committee, where every manager involved had some pet project that NEEDED to be included for some asinine reason.
Personal anecdote time: I had my interns start on Jira this summer. Three days in, I realized they weren't "getting" it because of how many damn buttons and knobs there are in the Jira UI. So, I switched all their issues to GitHub issues, and they went from having ~20 tickets in the project to over 100, and began adding, grooming, and closing their own without any input or direction from me. Sure, it's lackluster from an automation perspective, but they developed their own tagging system in the span of a few days and maintained their own board all summer.
I loved Atlassian for BitBucket in college, but when I entered the workforce and was forced to use Jira and Hipchat, I lost all love for them.
"git undo" : undo the last git command line, whatever it did. Especially if you don't understand what it did or it overwrote local files.
https://github.com/tj/git-extras/blob/master/bin/git-undo
It won't help you if you don't understand what the last command did or when it overwrote local files; it'll just make everything worse.
After trying to find something I liked, I ended up porting crecord extension for Mercurial to Git: https://github.com/andrewshadura/git-crecord
If you had a look you'd see git add -i is not even close to it ;)
There are a number of git shortcuts defined in my zsh aliases [0]. It goes like:
# Git aliases
alias g='git'
alias ga='git add'
alias ghb='git browse' # hub
alias ghpr='git pull-request' # hub
alias gp='git push'
alias gpoh='git push origin HEAD'
...
Using these aliases, we rarely have to type more than 3-4 characters for a git command. Savings and efficiency not only add up over years of using git, but also accelerate as you become more proficient in using your own aliases that fit your special needs.[0] - https://github.com/sungwoncho/dotfiles/blob/master/zsh/alias...
Whenever I have to touch git and `git co` doesn't work, I think, okay, fine, we'll go through the full dress rehearsal; `git checkout` it is.
Another tip, I only occasionally need git autocompletion withh aliases, but in zsh you can do something like this:
# Enable zsh git completion for our aliases.
# See https://github.com/mislav/dotfiles/blob/d82e79b8a500891a02ab28171974d68be7a35e12/shrc/git.sh
if [ -n "$ZSH_VERSION" ]; then
compdef _git g=git
compdef _git gc=git-commit
compdef _git gco=git-checkout
compdef _git gd=git-diff
compdef _git gb=git-branch
compdef _git gst=git-status
compdef _git gp=git-push
compdef _git gd=git-diff
fi
And obviously bash has an equivalent.[1]: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases [2]: https://github.com/nickbarnwell/dotfiles/blob/master/home/.e...
[alias]
amend = commit --amend --no-edit
ls = ls-tree --name-only --full-name HEAD
tree = log --graph --decorate --oneline --all
commit-date = "!gitcommitdate() { (export GIT_COMMITTER_DATE=\"$1\" && git commit --date=\"${GIT_COMMITTER_DATE}\" \"${@:2}\"); } && gitcommitdate"
There's also a whole boatload of commands in git-extras for those interested: https://github.com/tj/git-extras/blob/master/Commands.mdhttps://github.com/GitAlias/gitalias
g f && g rom
git fetch && git rebase origin/master
You could go nuts and make it even shorter with https://github.com/thoughtbot/gitsh
gitsh > f & rom
Magit hasnt been slow for me since I upgraded to Emacs 26. Older versions of Emacs were not optimized for spawning processes on OSX and it was causing a 10x slowdown for some operations.
Just a few moments ago I had to kill Emacs because magit was executing this command:
git branch --remote --contains 10a1663bf96fActually magit is quite fine for small personal projects. It's just that it absolutely chokes on a large monorepo I'm working on.
I've been moving more and more to terminal for all of my development. My dev. stack is now: vim; tmux; lynx; ddgr; zsh; and docker. It is game changing for distraction-free programming, consistency between languages, and the ability to use the exact same setup everywhere -- even on remote machines.
Sharex is the other thing I mentioned, its screenshots/screenrecords on steroids, check it out.
This looks like it could be close, and I’ll definitely give it a try. If I could decouple myself a bit more from Sublime that would be great. The plugin community just isn’t the same as VS Code.
But I wanted single line commits so gave gitsavvy a go. I had to redefine a couple of shortcuts (Ctrl-D from Discard to diff) but it’s been excellent. The only thing I can’t get working is gitlab integration.
It’s a worth a shot.
I am a long time git tower user, and i have given GitKraken more than a few shots. I always go back to a hybrid command line and git tower workflow
go build -gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH
https://stackoverflow.com/a/45302415I don't think there's a way to remove the whole file paths other than replacing strings in the compiled binary. In our case GOPATH was the only sensitive part (since function names can't be removed either, for reflection to work).
We also couple it with a defer handler to obfuscate panic traces.
I commit like, once a day. What am I doing wrong?
There are so many ways to approach a problem in any given codebase, and I rarely know which will be the best without experimenting. Having tools that reduce the burden of experimentation and branching is incredibly powerful.
On the day to day work, git use is simple; it’s with large major version upgrades, refactors, merging many branches together, and spiking/research where the more advanced features really shine.
Personally, I like it when `git diff` displays only one or at most three screenfuls of changes that haven't been committed.
then got commit -v to verify the hunks
if people know an equivalent outside go, please comment
This tool looks like it does that a bit better with interactivity maintained, and for some reason i'm more comfortable accepting a CLI git UI into my workflow than a GUI.
Not a UI but helps with some commands you run in a row quite often
git_show_blame () {
if [ -z "$3" ]
then
printf "USAGE: git_show_blame filepath start_line_num end_line_num" && return 1
else
[ ! -z "$4" ] && printf "\\n${LPURP}[git_show_blame]${NC} Warning: extra arguments provided. Ignoring everything after the first 3\\n\\n"
git show $(git blame "$1" -L "$2","$3" | awk '{print $1}')
return $?
fi
}
Use with recursive search `grep -Rn your_regex .` to track down the original commit that your pesky coworker added two years ago without any corresponding documentation for an alert that's going critical at 2am...(only slightly exaggerating there :P)* I acknowledge that some really great skiers are geeked on their equipment and use a variety of skis. Point still stands.
GitX (Mac only sadly) is the best of the free ones, and Tower is then best of the commercial ones. Try those.
This is the most ridiculous ad ever.