Create Alias In Git

Create Alias In Git

In this tutorial i will use create alias for git commands using git. Alias is used for creating shorter commands that is synonym for more complex and longer commands which reduces the number of keystrokes. in git we can configure alias in two different ways first is local and second is global. Local configuration is valid only for local repository and global configuration can be accessible in any repository. So to demonstrate this i will create an alias  for pushing data to any branch usually i use git origin push origin_name  command to push files to remote repository.

[email protected]:~# git config --global alias.po "push origin"
[email protected]:~# git config --local alias.po "push origin"

so i have created two alias for push origin command as po on is locally configured and another is globally configured, to use this command you have to simply run command

[email protected]:~# git po branch_name

this command will push all commits changes to remote branch.You can also verify those aliases are created or not in.gitconfig file located at home directory(for global configuration), for local configuration you can see those alias in .git/.gitconfig file.

       po = push origin

As you can see in above code block my alias is created for push origin command.

Leave a Comment