Home > Software design >  Why is 'git add --al' with single 'l' working?
Why is 'git add --al' with single 'l' working?

Time:01-14

In git bash I typed git add --al (with single 'l') by mistake, and it worked. From the documentation I can't see the option with single 'l' letter.

I Searched on google and couldn't find any explanation.

Not important, just for curiosity: Now whenever I type --all I can't stop myself thinking "If I'm wasting my time with typing second 'l'" :)

#Git options abbreviation

CodePudding user response:

Abbreviating long form options is usually allowed, if the result is unambigous, according to the conventions (emphasis mine):

Many commands allow a long option --option to be abbreviated only to their unique prefix (e.g. if there is no other option whose name begins with opt, you may be able to spell --opt to invoke the --option flag), but you should fully spell them out when writing your scripts; later versions of Git may introduce a new option whose name shares the same prefix, e.g. --optimize, to make a short prefix that used to be unique no longer unique.

Since (as of now) --al only prefixes a single legal long option for git-add, it will be accepted as --all. Theoretically even gid add --a could work.

  • Related