Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 570
Joe Collins Avatar asked May 17 '12 18:05

Joe Collins


People also ask

What is the git commit command?

The git commit command captures a snapshot of the project's currently staged changes. Committed snapshots can be thought of as “safe” versions of a project—Git will never change them unless you explicitly ask it to.

How do I use a git Aliase?

Add git alias The simplest way to add a git alias is by running a command to add the alias to the git global configuration file. For example, running the command git config --global alias. hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short" will add the alias git hist .

How do I use echo in git?

When echoing something to a file, >> appends to the file and > overwrites the file. From the example you posted, a log directory is created and then *. log is put into log/. gitignore so that no log files are committed to git.

What git add does?

The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn't really affect the repository in any significant way—changes are not actually recorded until you run git commit .


1 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)

like image 190
Daenyth Avatar answered Oct 03 '22 02:10

Daenyth