I'm looking at the dotfile for git aliases here . Why is there an exclamation mark before the git add
? And looking at other aliases, quite a few use !
, in the formal of $alias_name$ = "!..."
. Are the two uses different?
I looked up some bash uses of !
and it seems to be used to get previous commands, but this use seems to be different. Any ideas? Thanks!
!
is not before git add
, it's before the entire command line. It means "run the command with a shell". Git aliases are usually simple substitutions:
[alias]
ca = commit -a
means that the command git ca
will be interpreted by git as git commit -a
.
For more complex tricks in aliases people use shell commands and functions, and !
calls shell. For the alias you pointed to it means that git ca
will execute
git add -A && git commit -av
in a shell.
The '!' is used to tell that the command that is between the double quotes is not a git command. The command will use one of the many command line executable installed on your system.
Indeed, you could call the git executable, so that this 2 alias are the same :
st = "status"
st = "!git status"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.