DEV Community

Ayowande Oluwatosin
Ayowande Oluwatosin

Posted on

Creating Aliases in git

Git aliases assist programmers to define key shortcuts for certain repeated commands, for example, php artisan can be 'pa'. This avoids the need for repetition of commands.

so how do we create aliases in git?

  • install git bash
  • open your bash
  • in the bash terminal run
vim ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode

this will open bash in the home directory or create one if it doesn't exist

  • type in your aliases, as many as you like. For example,
alias pa='php artisan'
alias model='php artisan make:model'
alias controller='php artisan make:controller'
Enter fullscreen mode Exit fullscreen mode
  • then press 'esc' key. then type ":wq" to close.
  • finally restart git bash
  • run 'alias ' to list all the aliases

Testing
now, in our terminal we may run the php server:

pa serve 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)