What is the meaning of the "bang" or "!" before the git command?

As you can see from this excerpt, there is a "!" before the git command. What's the point?

[alias]
commitx = !git add . && git commit

- https://stackoverflow.com/a/8956546/1354543

I understand aliases and what the command itself is doing, but not the point of the "!" before the git command.

Answers


The ! means "run the following as commands to the shell", so in this case the alias git commitx expands to the equivalent of running git add . && git commit (which is a terrible terrible idea)


An important aspect of ! not covered by the accepted answer is that for the shell command, the working directory is set to the top level of the working copy. Therefore, git commitx would stage then commit all new and changed files in the working copy, while running git add . && git commit manually would stage then commit all new and changed files in the current directory.


Need Your Help

What is the best or most interesting use of Extension Methods you've seen?

c# .net extension-methods syntactic-sugar

I'm starting to really love extension methods... I was wondering if anyone her has stumbled upon one that really blew their mind, or just found clever.