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.
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.
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 .
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.
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 .
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With