helTech
helTech

Reputation: 95

Create alias with git like gits or gitxxx

I want to create alias with git so as to have someting like gitxxx:

for example, instead of :

git statut

I want

gits

thank you in advance.

Upvotes: 1

Views: 378

Answers (2)

Doon
Doon

Reputation: 20232

you would need to use a shell alias

something like alias gits='git status'

[projects/iadmin] gits                                      (git-svn)-[master]
zsh: command not found: gits
[projects/iadmin] alias gits='git status'                   (git-svn)-[master]
[projects/iadmin] gits                                      (git-svn)-[master]
On branch master
nothing to commit, working directory clean

This assumes a *nix like environment and sh based shell. But as others have pointed out, you cannot use internal git aliases as you would still need to prefix with git..

I also use shell functions for some of this.

from my zshrc

# No arguments: `git status`
# # With arguments: acts like `git`
g() {
  if [[ $# > 0 ]]; then
    git $@
  else
    git status
  fi
}

Upvotes: 1

shankar kumar
shankar kumar

Reputation: 648

alias of git can be create like this command

git config --global alias.co checkout

for further reference please check

https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases

Upvotes: 1

Related Questions