Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can git switch options be shortened?

Tags:

git

Can git commit -a -m "commit msg" be shortened to git commit -am "commit msg" and work as expected?

Basically, can options be given as "short" switches and let the last switch accept an argument?

like image 516
RyanScottLewis Avatar asked Dec 22 '22 13:12

RyanScottLewis


1 Answers

Yes.

Well-written Unix commands let you coalesce multiple single-letter options behind a single hyphen, as long as none of the options except the last one in the group can take an argument. Git is one of these well-written commands.

Many people who haven't spent much time in the Unix shell don't realize this, and unfortunately, sometimes those people end up writing command-line utilities that don't use the standard getopt(3) to parse their options, and end up writing their own parser that doesn't allow you to coalesce options in the standard way like this. So there are some poorly-written commands that don't allow that. Luckily, git is not one of those poorly-written commands.

like image 189
Spiff Avatar answered Jan 04 '23 08:01

Spiff