1

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

2

3 Answers 3

6

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!

Sign up to request clarification or add additional context in comments.

4 Comments

@chiragsorathiya, type cd ~ then vim .bashrc
not working alias gc="git commit" and alias gp="git push"
@chiragsorathiya did you do echo 'alias gc="git commit"' >> ~/.profile ? You also need to restart the shell. ~ is short for the current users home directory.
Nothing but echo 'alias gst="git status"' >> ~/.bashrc worked for me in Ubuntu18.04.
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.

Comments

0

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

Git Basics - Git Aliases

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.