4 ms·
> 1. If a new version of git adds a command that shadows one of your aliases, you'd really prefer "git foo" to silently run the new command? Yes. Otherwise co
by the_mitsuhiko 14y ago
> 1. If a new version of git adds a command that shadows one of your aliases, you'd really prefer "git foo" to silently run the new command?
Yes. Otherwise command line scripts will start doing horrible things. It was never intended that you can alias builtins, the only reason you might think you can is because it is allowed in mercurial which I think is a horrible idea.
> `git checkout -- somefile.py` does not have anything to do with checking out a revision.
Of course not. `git checkout` checks out things. You can check out a lot of things. Just because it works differently in hg does not mean it's wrong in git. git checkout does what it says on the tin: it checks out a branch or paths to the working tree.
> I like Mercurial's named branches because I don't need to create a branch for every single commit.
I think the concept of named branches in mercurial are hugely flawed and were the final nail in the coffin of why I migrated over to git. And I never looked back.
> What if you want the current branch in your prompt?
Then you use the underlying low-level commands or even better, you cat `.git/HEAD` which will be even faster. Not sure why for your prompt to look nice you need to have non-cryptic commands. Exactly for things like prompts there is the plumbing.
> gives you the same power as Git and has a UI where "--help x", "-h x", "help x", "x -h", and "x --help" all do the same thing
How is this different from mercurial? If anything mercurial has even more ways to show help: `man hg` which shows the manpage for all the builtin commands. `hg help` which shows a short version or `hg -v help` which shows a long version (which is not the man page). git only has two help pages: man pages for long and short text for short.
> gives you the same power as Git
I have yet to see this.
- micampe 14y ago> Yes. Otherwise command line scripts will start doing horrible things. It was never intended that you can alias builtins, the only reason you might think you can is because it is allowed in mercurial which I think is a horrible idea. You should understand what you are responding to before typing your answer. Say today I create an alias “boom = <whatever>” and next week git introduces a boom command. Now my alias is ignored, my scripts are broken and I might destroy my working copy or kill my cat by using it without knowing it now means something else. Git gives some very stupid hints “branhc is not a git command, did you mean branch?” it should also warn me when I defined an invalid alias. Maybe that alias was valid two versions ago or I just don’t know that command exists, since there are eleventy thousand of them.
- the_mitsuhiko 14y ago> Now my alias is ignored, my scripts are broken and I might destroy my working copy or kill my cat by using it without knowing it now means something else. Your scripts should not rely on aliases you have in your config. Scripts are intended to be used by different people.
- micampe 14y agoI decide who is intended to use my scripts, thank you. I have many scripts where I am the only user. Also, the issue of having an alias changing behavior without warning on my command line still exists.
- salgernon 14y ago>> Git gives some very stupid hints “branhc is not a git command, did you mean branch?” it should also warn me when I defined an invalid alias. This is the thing that really infuriates me - having a message from my tool that tells me there's an error is one thing, but offering a (frequently incorrect) correction forces me stop and try to figure out why this suggestion was offered, since it frequently has NOTHING to do with what I actually (mis)typed. Lets put it this way - if this autocorrection feature is so great, then it should prompt you Y/N after giving the error message. Would it then be a better feature? Or would it make more people want to stab it in the eyeballs? Or if this suggestion feature is so great, then it should just DWIM in the first place. Someone needs to take gits levenshtein algorithm away.
- rson 14y ago> Or if this suggestion feature is so great, then it should just DWIM in the first place. It can do this if you tell it do. The following tells git to wait 10 tenths of a second before executing the corrected command, giving you time to cancel if it is incorrect. git config --global help.autocorrect 10
- stevelosh 14y agoIf your solution to "get the current branch" is "cat out this magic data file that happens to exist in the data directory" then we have completely incompatible definitions of "user interface" and are never going to agree on this.
- wonderzombie 14y agoThe question was not how to just get the current branch, thought, right? As pointed out already, `git branch` does that. The question was how to do it programmatically, and there are multiple ways to do it. You might still call that user interface, but it's that's a stretch; fancy shell magic like branch-in-prompt is typically write-once.
- Anderkent 14y ago`git branch` doesnt do that. `git branch | less` followed by search might, if I remember some part of the branch name well enough to search for it. Printing all the branches and having me scroll two screens up to find the one that's in color is not a solution to 'what branch am i on'
- fr0sty 14y agogit branch gives you a nice asterisk too: $git branch * MyBranch NotMyBranch It prints the branch as the first line of git status: $git status # On branch Foo ... It also ships with a 'bash-competion' file which gives you a very simple way to disply the current branch (among other things) rather simply. And of course you can also create your own alias if it is something you wish to do often.
- philwelch 14y agoWhy are you keeping hundreds of branches open at a time?
- kyrias 14y agoIf you want the branch in your prompt you should use the script that is shipped with git.
- Anderkent 14y ago>I think the concept of named branches in mercurial are hugely flawed and were the final nail in the coffin of why I migrated over to git. And I never looked back. How does having more information available ever hurt you? Now, fair enough, the fact that mercurial expects branches to be unique might be annoying if you have the tendency to call all branches 'bugfix', but you seem to imply that simply having the branch name in which the commit was originally created as metadata on it would be somehow bad. >git checkout does what it says on the tin: it checks out a branch or paths to the working tree. 'git checkout is good because checkout means the thing that git checkout does' riiiiight