As placed by another answer, you can use the command alias
. However, this approach only allows you to create them in environments that have this command. Windows, for example, would be out.
However, Git also gives you the option to set aliases using its own interface. This means that you still need to use the command git
to access them.
For example, to create a alias git ac
, that rotates the commands git add .
and git commit
, you can do:
# Criamos um alias com nome "ac"
# ↓↓
git config --global alias.ac '!git add . && git commit'
It is worth noting that as we did not pass any message to the commit
, it will open an editor so that you can insert a message. In addition, the exclamation mark was used in the beginning to make it possible to execute external commands, since by default you can only create aliases for an existing subcommand. For example:
git config --global alias.l 'log --oneline --abbrev'
Note that we don’t even need to have put the git
in front of the log
.
To learn more, read the documentation. There is also a excellent Gist on the subject, in Portuguese.
Linux or Windows environment?
– ℛɑƒæĿᴿᴹᴿ
Luiz, if the answer solved your problem please mark the answer as accepted, if you still have any questions ask so that we can clarify. Hug!
– ℛɑƒæĿᴿᴹᴿ