
Git git git git git - caiusdurling
http://caiustheory.com/git-git-git-git-git/
======
gulperxcx
>I quite often type git then go away and come back, then type a full git
status after it.

Does anyone else actually do this besides OP. I've never heard of this problem
until now.

~~~
perlgeek
I do. And I also write "vim vim thefile.txt" and stuff like that.

Finally I've written a small shell function that corrects "gi tpull" to "git
pull", because that happens at least once a day.

~~~
projektfu
I always typed rebnoot, so I patched Netbsd to allow rebnoot. Then I patched
it still so it would say, "Rebnooting". Fun times.

~~~
dbcurtis
Relatable. For years, I aliased mroe to more. Now I alias mroe and more to
less.

My wife drafts a lot of legal documents, and has a problem with "doe snot".
Which unfortunately the spelling checker is perfectly happy with.

~~~
Singletoned
There's defintitely room for an advanced spell checker that can say "This is
valid, but probably wrong".

~~~
MikeTV
I just ran across Language Tool[0] recently. Free, open-source proofreading
lib, can be run totally locally. Uses Google Ngrams to check for often
confused words. Didn't correct "doe snot" in my synthetic test just now, but
that seems like a plausibly minor extension of existing functionality.

[0] [https://www.languagetool.org/](https://www.languagetool.org/)

------
Waterluvian
I want a terminal that highlights things it thinks are off. Like when I type
cd cd or git git. But I don't want it to auto fix nor wait until the command
is issued to complain.

This is because I want to be the sole controller of what command is actually
issued. Call me an old curmudgeon but I just don't trust the auto fix
solutions.

Edit: had no idea about Fish. Thank you, all.

~~~
nlo
Fish shell like syntax highlighting for zsh: [https://github.com/zsh-
users/zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-
highlighting)

Fish-like autosuggestions for zsh: [https://github.com/zsh-users/zsh-
autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)

~~~
Vinkekatten
Or if you don´t care for fiddling about too much and just want it to work out
of the box: [http://ohmyz.sh/](http://ohmyz.sh/)

------
bowmessage
Why type out `git status`? I use `gst`, and lots of other great aliases
provided by the [oh-my-zsh git plugin]([https://github.com/robbyrussell/oh-my-
zsh/blob/master/plugin...](https://github.com/robbyrussell/oh-my-
zsh/blob/master/plugins/git/git.plugin.zsh))

~~~
Analemma_
I used to do that, but I found it wasn’t actually saving me any cognitive
load.

My newer philosophy toward git aliases is the one described here:
[http://gggritso.com/human-git-aliases](http://gggritso.com/human-git-
aliases). After reading this I totally overhauled my .gitconfig and replaced
it with the one described here and I’m a lot happier.

~~~
pmoriarty
I don't use either one anymore. I've switched to magit, which is faster than
both and can also give you interactive menus and reminders of commands if you
want.

------
notthemessiah
The mathematical term for a function that is the same when applied multiple
times giving you the same results is called "idempotent" which translates to
"same power". f^n(x)=f(x) for some positive natural number n and any x.

[https://en.wikipedia.org/wiki/Idempotence](https://en.wikipedia.org/wiki/Idempotence)

~~~
hellofunk
I had a senior dev interview with a major company in SV last year where the
lead and hiring manager claimed that the description for this behavior was
"side-effect free".

I didn't want to ruin my chances by correcting him that side-effects and
idempotence refer to different qualities.

I passed the interview, but I've never forgotten that. The guy also seemed to
have washed into the interview off his surf board.

Oh well. It was a very major company, so I let it all go.

~~~
dylanpyle
In the context of software it seems like the word has pretty broadly adopted
the meaning of "side-effect free". It's even made it to Wikipedia:
[https://en.wikipedia.org/wiki/Idempotence#Computer_science_m...](https://en.wikipedia.org/wiki/Idempotence#Computer_science_meaning)

One notable example: Stripe's "idempotency keys":
[https://stripe.com/blog/idempotency](https://stripe.com/blog/idempotency)

~~~
twic
I understand 'idempotent' not as 'having no side effects' but as 'having the
same side effects whether performed one or many times'. This is side-effect
free:

    
    
      echo hello
    

This is side-effectful, but idempotent:

    
    
      echo hello >world
    

This is side-effectful and not idempotent:

    
    
      echo hello >>world

~~~
ComputerGuru
I disagree that your ‘ echo hello’ example is free of side effects. It writes
to stdout. It overwrites $?. It changes the value of the last executed history
command. Etc.

About the only side effect free operation at a blank line terminal prompt is
_probably_ hitting enter or ctrl c. Or ‘#something<Enter>’

But your idempotency examples are spot on.

Basically, idempotency is a very useful concept. Side effect free isn’t.

~~~
twic
> I disagree that your ‘ echo hello’ example is free of side effects.

I posit that you understand perfectly well what i was getting at! If it helps,
imagine that you are spawning a fresh shell to execute each command line,
through system(3) or some such.

~~~
ComputerGuru
Fair enough!

------
empath75
You can also just use 'fuck' for this:

    
    
      > git git pull
      git: 'git' is not a git command. See 'git --help'.
    
      The most similar command is
    	init
    
      > fuck
      git pull [enter/↑/↓/ctrl+c]

~~~
web007
AKA [https://github.com/nvbn/thefuck](https://github.com/nvbn/thefuck)

------
js2
Author missed an opportunity to title this "Git git Git git git git Git git."

[https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffal...](https://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo)

------
metrognome
Quite often, I accidentally press the space bar eagerly when typing git
commands:

    
    
        $ gi tstatus
    

To fix this, I've added the following to my .bashrc:

    
    
        gi() {
            args=("$@")
            args[0]=${args[0]/t/}
            git "${args[@]}"
        }
    

It also works if you drop the "t" altogether.

~~~
QuercusMax
Ha! I have almost the same thing:

gi() { ARG=$(echo $1 | sed s/^t//); shift; git "$ARG" "$@"; }

------
nu11p01n73R
> git config --global alias.git '!exec git'

Is the exec really required?

    
    
       git config --global alias.git '!git'
    

Will also work. Am I missing something?

EDIT: From git doc, "If the alias expansion is prefixed with an exclamation
point, it will be treated as a shell command"

So exec is not required then.

~~~
vesinisa
You are right, I checked and the resulting sub-process tree is the same
regardless of whether !git or !exec git is used.

Also, I found one caveat from the same docs:

> Note that shell commands will be executed from the top-level directory of a
> repository, which may not necessarily be the current directory. GIT_PREFIX
> is set as returned by running git rev-parse --show-prefix from the original
> current directory.

So, if I have a modified file `bar` in subdirectory `foo` under project root,
and I am currently in `foo`, git status will show:

    
    
        modified:   bar
    

but git git status will show:

    
    
        modified:   foo/bar
    

To fix this, we should use cd first:

    
    
        git config --global alias.git '!cd "$GIT_PREFIX" && git'

------
salgernon
erm, "git git foo"; in most shells can be fixed with "!*" as your next
command. Repeat until lameness subsides.

Seriously though, I don't understand why people want to hide obvious errors
like this - I'd much rather have the tool fail to execute than potentially
perform some action I wasn't expecting.

~~~
shawncplus
Exactly. If anything I appreciate when errors are _highlighted_ a la `sl`
(Steam locomotive) for `ls` or the `gti` for `git` that has a golf gti run
across the screen

------
mimo84
I never had the problem mentioned in the article, but for misspelled commands
I trust git autocorrect:

git config --global help.autocorrect 1

It will run the correct misspelled command after 100ms. For example git stauts
will be corrected automatically to git status
[http://schacon.github.io/git/git-
config.html](http://schacon.github.io/git/git-config.html)

------
hackbinary
I tend to type Ctrl-C then a command. Ctrl-C clears the line for you, so you
can be sure that you are starting on a fresh line.

------
bandrami
While the cleverness is admirable, there comes a point in your life when you
realize you really do always want your own errors to fail loudly and
immediately.

~~~
ReFruity
That is true given automatic error correction can backfire, I don't see how
git git -> git autocorrect can backfire.

~~~
bandrami
The backfires you can see ahead of time are never the problem, are they? :)

------
z3t4
Sudo should stop working if your error rate rises to unusual high

------
sgloutnikov
Here are a number of great aliases that people might find helpful:

[http://durdn.com/blog/2012/11/22/must-have-git-aliases-
advan...](http://durdn.com/blog/2012/11/22/must-have-git-aliases-advanced-
examples/)

------
steventhedev
`!exec git` caused my shell to exit. I have a lot of stuff wrapping git in my
shell though (including a bash function wrapping git itself!). The author
himself only pushed up the change to his own gitconfig a few hours ago. It was
previously `!$SHELL -c \"git $*\"`.

My version that works for my setup is `"!f() { git \"$@\"; }; f"`.

Hope this helps anyone who ran into the same issue, although I'm not 100%
confident about the quoting.

EDIT: fixed the quoting, as per cryptonector's suggestion

EDIT2: need to quote the quotes for gitconfig to use it correctly

~~~
cryptonector
Add double quotes around $@.

------
moogly
Well... If you have this problem (I really don't), then you probably have it
with more than just git, and the proposed workaround would be "a local
solution to a global problem".

------
abecedarius
Reminds me of this Python line:

    
    
        decorator = decorator(decorator)(decorator)
    

[https://github.com/darius/sketchbook/blob/master/misc/decora...](https://github.com/darius/sketchbook/blob/master/misc/decorator.py)

There was a subtle bug when leaving out the last (decorator). I know, it's
very silly.

------
isarat
I have homegrown aliases like 'tags' 'rdel' (git push origin --delete) 'ldel'
(git branch --delete) and many more combined with Zsh's (Oh my Zsh)'s several
aliases (e.g ggpull, glog, gp, gc) etc.

I also find "thefuck" is interesting but I love to control my fate :)
([https://github.com/nvbn/thefuck](https://github.com/nvbn/thefuck))

------
shiven
Why type the singular, "git", so many times? We all know that you mean the
plural "gits"!

    
    
       alias gits='git status'

------
kobeya
This post would have been a lot better if he showed how to do a git subcommand
that launched itself, which is where i thought he was going.

~~~
ekimekim
This isn't too hard. Aliases can expand to arbitrary shell commands, as shown
in the article. So you can do something like:

    
    
        git config --global alias.bomb '!git bomb & git bomb'
    

to make a fork bomb.

------
shruubi
This reminds me of something I read long ago that was along the lines of "make
the computer change for you, don't change for the computer". As such, I have a
small list of common typo's that I make that alias themselves to their correct
forms.

Since then, I've found that these aliases have been the best workflow
improvement I've ever made.

------
Myrmornis
This is nice specifically because of the way the author uses `exec`. Without
meaning to be patronizing, there must be lots of people reading the thread who
don't know what `exec` does, and why it's a neat solution to this problem (or
non-problem, whatever your view is); I'd say do look it up if you're
interested in programming.

~~~
caiusdurling
Author here, I'm glad someone else appreciated it besides me. :-)

(It's especially pleasing to watch the system calls it generates via strace or
dtrace!)

------
itsashis4u
After setting this alias in .gitconfig, I tried `git git log`

Works fine, but when I press quit (q), it says `error: exec git died of signal
13`

------
yeukhon
As I was reading the article, I heard "git git git git" in the glitch audio
form in my head... anyone?

~~~
hupperz
I heard Desiigner.. completed the title in my head with "I got broads in
Atlanta"

~~~
literallycancer
I can't hear that one without thinking of this :D

[https://soundcloud.com/joshpan/panda-desiigner-
adlibs](https://soundcloud.com/joshpan/panda-desiigner-adlibs)

------
busterarm
I sometimes have this problem but I hate solutions like this because I figure
if I make this kind of mistake, I'm not paying sufficient enough attention to
what I'm doing at the moment.

I take a minute, clear out distractions and then come back to what I'm working
on.

------
kazinator
Great for C programmers. Goes with:

    
    
      printf("Hello, world!\n");
      (printf)("Hello, world!\n");
      (*printf)("Hello, world!\n");
      (**printf)("Hello, world!\n");
      (***printf)("Hello, world!\n");

------
asveikau
The danger of this is if you accidentally write 'git git something' into a
shell script and it works on your machine, then you commit the script to a
repo and it doesn't work for anyone else.

I suppose this is a problem with any alias.

~~~
xelxebar
One way around that issue is to prefix commands you intend to share with
backslash:

    
    
        $ \gstatus
        gstatus: command not found
    

vs

    
    
        $ gstatus
        git status stuff
    

The backslash just disables alias expansion. This works on all shells I'm
aware of. It won't help with other portability concerns like actual missing
commands though, of course.

------
Breakthrough
It would be cool if you could generalize this for anything (e.g. ls ls -al).
That being said, I wonder if there's any actual command-line utilities that
actually use a similar syntax to perform something useful.

------
jes5199
great minds think alike? I've had this exact system for a long time:
[https://github.com/jes5199/git-git](https://github.com/jes5199/git-git)

------
Walkman
There is a GitHub repository full of neat tricks like this:
[https://github.com/GitAlias/gitalias](https://github.com/GitAlias/gitalias)

------
temporallobe
I often type "git stats" but I've never felt the need to go through all of
this just because I'm lazy. Then again maybe that's an ironic example of
laziness.

------
bradezone
Why type "git" and walk away? Seems like an ultra edge case that deserves
whatever ill comes from it.

------
taejo
Does anyone else do `qgit`? `q` to quit the pager, but the output of the
previous command unexpectedly fit on one screen.

------
tardo99
I thought everyone used shortcuts for git. e.g.: `gs` means `git status` or
`gpom` means `git pull origin master` etc

------
jrimbault
C-w would have solved that problem quickly :)

------
cup-of-tea
Why is this a problem? Is the author blind? If this happens with git then
surely it happens with every command. What about "rm"? What if I type "rm
-Rf", leave, then come back and type something else? Maybe a better solution
is to change behaviour, or if there really is some reason for this behaviour,
have something delete the currently entered command after it's been idle for
some seconds.

~~~
olalonde
I think it was meant as light hearted humor.

------
lamflam
I find this much simpler: ln -s $(which git) [some dir in your $PATH]/git-git

------
mbrumlow
No, no I have not ever had too many gits...

(is this really a thing?)

------
IgorPartola
apt-get install sl

~~~
IgorPartola
Also `alias gti="echo 'vroom vroom'"`

------
negativ0
yeah it's nice, git git happens! I have a lot of this shortcuts for git, zsh
and especially for vim (:Q, :Qall, :QALL etc...)

------
stereobit
Nearly as good as

alias gti=git

~~~
Walf
Don't forget "igt".

------
xelxebar
Off-topic, but this site is pretty.

------
deeteecee
typing that means you probably needs some rest to let your brain refuel imo.

------
alex_duf
also, I had to add alias got='git' in my bashrc. Typo galore.

------
alkz
how about looking at what you type instead of the keyboard?

------
Keloran
you can also just get away with git = !"git"

------
rurban
At first alias g=git

------
alexchamberlain
This is a manager problem, right?

------
4ad
This is a joke, right? It has to be a joke.

------
hellofunk
At first I thought this title was pointing to the quirky symptom of Clojure's
default value for the "get" function that allows this statement:

(get get get get)

to be equivalent to this one:

get

as in:

((get get get get) {:a 1} :a)

I was very excited about an article on this topic.

