Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortcuts for git commands

Tags:

git

I would like to use shortcuts or aliases for git commands.

git diff git status git push  git pull git stash git branch -a 

How do I create shortcuts or aliases, is there a predefined list?

like image 222
Sam Avatar asked Feb 07 '13 14:02

Sam


People also ask

How do I add a shortcut to git?

Add git alias The simplest way to add a git alias is by running a command to add the alias to the git global configuration file. For example, running the command git config --global alias. hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short" will add the alias git hist .

How do you write commands in git?

Press 'Start' button in Windows, type 'cmd' in the search field on the bottom of menu. There you have the command line console. Try to type git --version , if show something like 'git version 1.8. 0.2', you're ready to input all the commands here.

What is a git alias?

Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands. Using Git aliases will make you a faster and more efficient developer. Aliases can be used to wrap a sequence of Git commands into new faux Git command.


2 Answers

Put this into your .gitconfig

[alias]   st = status   ci = commit   br = branch   co = checkout 

You can add as much as you want

like image 57
ogzd Avatar answered Sep 22 '22 15:09

ogzd


git config --global alias.<short> <long> 

e.g.

git config --global alias.cob "checkout -b" 

(Without --global, you get per-project aliases.)

like image 27
Fred Foo Avatar answered Sep 18 '22 15:09

Fred Foo