Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I alias commands in git?

Tags:

git

git-alias

I saw a screencast where someone had gotten

git st git ci 

to work. When I do it I get an error asking me if I meant something else.
Being a git newb, I need to know what you have to do to get this done?

like image 845
DevelopingChris Avatar asked Mar 31 '10 14:03

DevelopingChris


People also ask

How do I make an alias command in git?

It is important to note that there is no direct git alias command. Aliases are created through the use of the git config command and the Git configuration files. As with other configuration values, aliases can be created in a local or global scope.

Where do I put git alias?

Your git aliases are often stored per your user's configuration at ~/. gitconfig . You can also manually set aliases using, for example, the command git config alias. s 'status -s' .

What is alias in git?

2.7 Git Basics - Git Aliases This means that, for example, instead of typing git commit , you just need to type git ci . As you go on using Git, you'll probably use other commands frequently as well; don't hesitate to create new aliases.


1 Answers

Basically you just need to add lines to ~/.gitconfig

[alias]     st = status     ci = commit -v 

Or you can use the git config alias command:

$ git config --global alias.st status  

On unix, use single quotes if the alias has a space:

$ git config --global alias.ci 'commit -v' 

On windows, use double quotes if the alias has a space or a command line argument:

c:\dev> git config --global alias.ci "commit -v" 

The alias command even accepts functions as parameters. Take a look at aliases.

like image 66
Diego Dias Avatar answered Sep 30 '22 12:09

Diego Dias