0

Now i use ubntu 17.10.

How to change git command for example

  • git add . command like ga,
  • git commit command like gc
  • git push commans lije `gp

other example like $ git add command like $ ga

when i typing ga then it work like git add

chirag sorathiya
  • 1,223
  • 8
  • 29
  • 2
    Possible duplicate of [How do I alias commands in git?](https://stackoverflow.com/questions/2553786/how-do-i-alias-commands-in-git) – Ashish Mathew Feb 06 '18 at 09:19
  • 1
    Possible duplicate of [How do I create a Bash alias?](https://stackoverflow.com/questions/8967843/how-do-i-create-a-bash-alias) – Ken Y-N Feb 06 '18 at 09:21

3 Answers3

5

Consider using Git aliases e.g.

git config --global alias.co checkout

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

To achieve exactly what you want you can use bash aliases

in your bash prompt type

alias ga="git add ."

This will only be valid until you close your shell. To have your aliases be persistent add them to your ~/.profile file.

echo 'alias ga="git add ."' >> ~/.profile

Ubuntu uses ~/.profile instead of ~/.bash_profile.

Best of luck!

Mr.Christer
  • 692
  • 1
  • 10
  • 12
1

You want to use aliases within your shell. For Bash:

echo "alias ga='git add .'" >> ~/.bash_profile
echo "alias gc='git commit'" >> ~/.bash_profile
echo "alias gp='git push'" >> ~/.bash_profile

Or, for ZShell

echo "alias ga='git add .'" >> ~/.zshrc
echo "alias gc='git commit'" >> ~/.zshrc
echo "alias gp='git push'" >> ~/.zshrc

Once run, simply open your new terminal.

tgallacher
  • 1,594
  • 1
  • 10
  • 7
0

If i understood your question correctly then below is detailed explanation of how to use alias

Git Basics - Git Aliases

Sudhakar
  • 324
  • 3
  • 9
  • This will alias the `git` sub-command. So instead of `git push`, you can alias that to be `git p` -- i.e. the alias only applies to the git command, not the parent git cli. Hope that makes sense. – tgallacher Feb 06 '18 at 09:22