TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Git git git git git

510 点作者 caiusdurling超过 7 年前

50 条评论

gulperxcx超过 7 年前
&gt;I quite often type git then go away and come back, then type a full git status after it.<p>Does anyone else actually do this besides OP. I&#x27;ve never heard of this problem until now.
评论 #15341976 未加载
评论 #15342052 未加载
评论 #15342409 未加载
评论 #15342356 未加载
评论 #15342065 未加载
评论 #15342531 未加载
评论 #15342378 未加载
评论 #15341905 未加载
评论 #15342042 未加载
评论 #15341995 未加载
评论 #15342266 未加载
评论 #15344010 未加载
评论 #15346595 未加载
评论 #15342284 未加载
评论 #15341903 未加载
评论 #15342263 未加载
评论 #15341951 未加载
评论 #15343887 未加载
评论 #15342367 未加载
评论 #15346964 未加载
评论 #15342554 未加载
评论 #15341883 未加载
评论 #15342587 未加载
评论 #15346038 未加载
评论 #15342007 未加载
评论 #15341998 未加载
评论 #15341988 未加载
评论 #15342317 未加载
评论 #15345622 未加载
评论 #15342564 未加载
评论 #15347140 未加载
评论 #15342139 未加载
Waterluvian超过 7 年前
I want a terminal that highlights things it thinks are off. Like when I type cd cd or git git. But I don&#x27;t want it to auto fix nor wait until the command is issued to complain.<p>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&#x27;t trust the auto fix solutions.<p>Edit: had no idea about Fish. Thank you, all.
评论 #15341746 未加载
评论 #15341728 未加载
评论 #15341722 未加载
评论 #15341931 未加载
bowmessage超过 7 年前
Why type out `git status`? I use `gst`, and lots of other great aliases provided by the [oh-my-zsh git plugin](<a href="https:&#x2F;&#x2F;github.com&#x2F;robbyrussell&#x2F;oh-my-zsh&#x2F;blob&#x2F;master&#x2F;plugins&#x2F;git&#x2F;git.plugin.zsh" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;robbyrussell&#x2F;oh-my-zsh&#x2F;blob&#x2F;master&#x2F;plugin...</a>)
评论 #15341937 未加载
评论 #15343711 未加载
评论 #15341763 未加载
评论 #15342129 未加载
评论 #15342192 未加载
评论 #15342776 未加载
评论 #15346844 未加载
notthemessiah超过 7 年前
The mathematical term for a function that is the same when applied multiple times giving you the same results is called &quot;idempotent&quot; which translates to &quot;same power&quot;. f^n(x)=f(x) for some positive natural number n and any x.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Idempotence" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Idempotence</a>
评论 #15341875 未加载
empath75超过 7 年前
You can also just use &#x27;fuck&#x27; for this:<p><pre><code> &gt; git git pull git: &#x27;git&#x27; is not a git command. See &#x27;git --help&#x27;. The most similar command is init &gt; fuck git pull [enter&#x2F;↑&#x2F;↓&#x2F;ctrl+c]</code></pre>
评论 #15342069 未加载
js2超过 7 年前
Author missed an opportunity to title this &quot;Git git Git git git git Git git.&quot;<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Buffalo_buffalo_Buffalo_buffal...</a>
metrognome超过 7 年前
Quite often, I accidentally press the space bar eagerly when typing git commands:<p><pre><code> $ gi tstatus </code></pre> To fix this, I&#x27;ve added the following to my .bashrc:<p><pre><code> gi() { args=(&quot;$@&quot;) args[0]=${args[0]&#x2F;t&#x2F;} git &quot;${args[@]}&quot; } </code></pre> It also works if you drop the &quot;t&quot; altogether.
评论 #15344867 未加载
nu11p01n73R超过 7 年前
&gt; git config --global alias.git &#x27;!exec git&#x27;<p>Is the exec really required?<p><pre><code> git config --global alias.git &#x27;!git&#x27; </code></pre> Will also work. Am I missing something?<p>EDIT: From git doc, &quot;If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command&quot;<p>So exec is not required then.
评论 #15345761 未加载
评论 #15345489 未加载
salgernon超过 7 年前
erm, &quot;git git foo&quot;; in most shells can be fixed with &quot;!*&quot; as your next command. Repeat until lameness subsides.<p>Seriously though, I don&#x27;t understand why people want to hide obvious errors like this - I&#x27;d much rather have the tool fail to execute than potentially perform some action I wasn&#x27;t expecting.
评论 #15351749 未加载
mimo84超过 7 年前
I never had the problem mentioned in the article, but for misspelled commands I trust git autocorrect:<p>git config --global help.autocorrect 1<p>It will run the correct misspelled command after 100ms. For example git stauts will be corrected automatically to git status <a href="http:&#x2F;&#x2F;schacon.github.io&#x2F;git&#x2F;git-config.html" rel="nofollow">http:&#x2F;&#x2F;schacon.github.io&#x2F;git&#x2F;git-config.html</a>
hackbinary超过 7 年前
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超过 7 年前
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.
评论 #15343498 未加载
z3t4超过 7 年前
Sudo should stop working if your error rate rises to unusual high
sgloutnikov超过 7 年前
Here are a number of great aliases that people might find helpful:<p><a href="http:&#x2F;&#x2F;durdn.com&#x2F;blog&#x2F;2012&#x2F;11&#x2F;22&#x2F;must-have-git-aliases-advanced-examples&#x2F;" rel="nofollow">http:&#x2F;&#x2F;durdn.com&#x2F;blog&#x2F;2012&#x2F;11&#x2F;22&#x2F;must-have-git-aliases-advan...</a>
steventhedev超过 7 年前
`!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 \&quot;git $*\&quot;`.<p>My version that works for my setup is `&quot;!f() { git \&quot;$@\&quot;; }; f&quot;`.<p>Hope this helps anyone who ran into the same issue, although I&#x27;m not 100% confident about the quoting.<p>EDIT: fixed the quoting, as per cryptonector&#x27;s suggestion<p>EDIT2: need to quote the quotes for gitconfig to use it correctly
评论 #15342103 未加载
moogly超过 7 年前
Well... If you have this problem (I really don&#x27;t), then you probably have it with more than just git, and the proposed workaround would be &quot;a local solution to a global problem&quot;.
abecedarius超过 7 年前
Reminds me of this Python line:<p><pre><code> decorator = decorator(decorator)(decorator) </code></pre> <a href="https:&#x2F;&#x2F;github.com&#x2F;darius&#x2F;sketchbook&#x2F;blob&#x2F;master&#x2F;misc&#x2F;decorator.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;darius&#x2F;sketchbook&#x2F;blob&#x2F;master&#x2F;misc&#x2F;decora...</a><p>There was a subtle bug when leaving out the last (decorator). I know, it&#x27;s very silly.
isarat超过 7 年前
I have homegrown aliases like &#x27;tags&#x27; &#x27;rdel&#x27; (git push origin --delete) &#x27;ldel&#x27; (git branch --delete) and many more combined with Zsh&#x27;s (Oh my Zsh)&#x27;s several aliases (e.g ggpull, glog, gp, gc) etc.<p>I also find &quot;thefuck&quot; is interesting but I love to control my fate :) (<a href="https:&#x2F;&#x2F;github.com&#x2F;nvbn&#x2F;thefuck" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nvbn&#x2F;thefuck</a>)
shiven超过 7 年前
Why type the singular, &quot;git&quot;, so many times? We all know that you mean the plural &quot;gits&quot;!<p><pre><code> alias gits=&#x27;git status&#x27;</code></pre>
kobeya超过 7 年前
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.
评论 #15341782 未加载
shruubi超过 7 年前
This reminds me of something I read long ago that was along the lines of &quot;make the computer change for you, don&#x27;t change for the computer&quot;. As such, I have a small list of common typo&#x27;s that I make that alias themselves to their correct forms.<p>Since then, I&#x27;ve found that these aliases have been the best workflow improvement I&#x27;ve ever made.
Myrmornis超过 7 年前
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&#x27;t know what `exec` does, and why it&#x27;s a neat solution to this problem (or non-problem, whatever your view is); I&#x27;d say do look it up if you&#x27;re interested in programming.
评论 #15347403 未加载
itsashis4u超过 7 年前
After setting this alias in .gitconfig, I tried `git git log`<p>Works fine, but when I press quit (q), it says `error: exec git died of signal 13`
yeukhon超过 7 年前
As I was reading the article, I heard &quot;git git git git&quot; in the glitch audio form in my head... anyone?
评论 #15345711 未加载
busterarm超过 7 年前
I sometimes have this problem but I hate solutions like this because I figure if I make this kind of mistake, I&#x27;m not paying sufficient enough attention to what I&#x27;m doing at the moment.<p>I take a minute, clear out distractions and then come back to what I&#x27;m working on.
kazinator超过 7 年前
Great for C programmers. Goes with:<p><pre><code> printf(&quot;Hello, world!\n&quot;); (printf)(&quot;Hello, world!\n&quot;); (*printf)(&quot;Hello, world!\n&quot;); (**printf)(&quot;Hello, world!\n&quot;); (***printf)(&quot;Hello, world!\n&quot;);</code></pre>
asveikau超过 7 年前
The danger of this is if you accidentally write &#x27;git git something&#x27; into a shell script and it works on your machine, then you commit the script to a repo and it doesn&#x27;t work for anyone else.<p>I suppose this is a problem with any alias.
评论 #15344987 未加载
评论 #15344207 未加载
Breakthrough超过 7 年前
It would be cool if you could generalize this for anything (e.g. ls ls -al). That being said, I wonder if there&#x27;s any actual command-line utilities that actually use a similar syntax to perform something useful.
jes5199超过 7 年前
great minds think alike? I&#x27;ve had this exact system for a long time: <a href="https:&#x2F;&#x2F;github.com&#x2F;jes5199&#x2F;git-git" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jes5199&#x2F;git-git</a>
Walkman超过 7 年前
There is a GitHub repository full of neat tricks like this: <a href="https:&#x2F;&#x2F;github.com&#x2F;GitAlias&#x2F;gitalias" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;GitAlias&#x2F;gitalias</a>
temporallobe超过 7 年前
I often type &quot;git stats&quot; but I&#x27;ve never felt the need to go through all of this just because I&#x27;m lazy. Then again maybe that&#x27;s an ironic example of laziness.
bradezone超过 7 年前
Why type &quot;git&quot; and walk away? Seems like an ultra edge case that deserves whatever ill comes from it.
taejo超过 7 年前
Does anyone else do `qgit`? `q` to quit the pager, but the output of the previous command unexpectedly fit on one screen.
tardo99超过 7 年前
I thought everyone used shortcuts for git. e.g.: `gs` means `git status` or `gpom` means `git pull origin master` etc
jrimbault超过 7 年前
C-w would have solved that problem quickly :)
cup-of-tea超过 7 年前
Why is this a problem? Is the author blind? If this happens with git then surely it happens with every command. What about &quot;rm&quot;? What if I type &quot;rm -Rf&quot;, 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&#x27;s been idle for some seconds.
评论 #15345908 未加载
lamflam超过 7 年前
I find this much simpler: ln -s $(which git) [some dir in your $PATH]&#x2F;git-git
mbrumlow超过 7 年前
No, no I have not ever had too many gits...<p>(is this really a thing?)
IgorPartola超过 7 年前
apt-get install sl
评论 #15342535 未加载
negativ0超过 7 年前
yeah it&#x27;s nice, git git happens! I have a lot of this shortcuts for git, zsh and especially for vim (:Q, :Qall, :QALL etc...)
stereobit超过 7 年前
Nearly as good as<p>alias gti=git
评论 #15347187 未加载
xelxebar超过 7 年前
Off-topic, but this site is pretty.
deeteecee超过 7 年前
typing that means you probably needs some rest to let your brain refuel imo.
alex_duf超过 7 年前
also, I had to add alias got=&#x27;git&#x27; in my bashrc. Typo galore.
alkz超过 7 年前
how about looking at what you type instead of the keyboard?
Keloran超过 7 年前
you can also just get away with git = !&quot;git&quot;
rurban超过 7 年前
At first alias g=git
alexchamberlain超过 7 年前
This is a manager problem, right?
4ad超过 7 年前
This is a joke, right? It has to be a joke.
评论 #15342423 未加载
hellofunk超过 7 年前
At first I thought this title was pointing to the quirky symptom of Clojure&#x27;s default value for the &quot;get&quot; function that allows this statement:<p>(get get get get)<p>to be equivalent to this one:<p>get<p>as in:<p>((get get get get) {:a 1} :a)<p>I was very excited about an article on this topic.