简体   繁体   English

在git add之前添加感叹号有什么意义?

[英]What is the point of adding an exclamation mark before git add?

I'm looking at the dotfile for git aliases here . 我期待在dotfile的git的别名这里 Why is there an exclamation mark before the git add ? 为什么在git add之前有一个感叹号? And looking at other aliases, quite a few use ! 并查看其他别名,有很多用途! , in the formal of $alias_name$ = "!..." . ,形式为$alias_name$ = "!..." Are the two uses different? 两种用途是否不同?

I looked up some bash uses of ! 我查了一下bash的用法! 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. 不是在git add之前,而是在整个命令行之前。 It means "run the command with a shell". 这意味着“使用外壳程序运行命令”。 Git aliases are usually simple substitutions: Git别名通常是简单的替换:

[alias]
ca = commit -a

means that the command git ca will be interpreted by git as git commit -a . 意味着命令git ca将被git解释为git commit -a

For more complex tricks in aliases people use shell commands and functions, and ! 对于别名的更复杂技巧,人们使用shell命令和函数,以及! calls shell. 调用shell。 For the alias you pointed to it means that git ca will execute 对于您指向的别名,这意味着git ca将执行

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. 用于告诉双引号之间的命令不是git命令。 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 : 实际上,您可以调用git可执行文件,以使这2个别名相同:

 st = "status" 

 st = "!git status" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM