How to define Git commands Aliases

I want to introduce a feature that can make your Git experience simpler, easier, and more familiar: aliases or shorthands

Method 1:

Git doesn’t automatically infer your command if you type it in partially. If you don’t want to type the entire text of each of the Git commands, you can easily set up an alias for each command using git config. Here are a couple of examples you may want to set up:

$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status
$ git config --global alias.ci 'commit -v'
c:\dev> git config --global alias.ci "commit -v"

Method 2:

Basically you just need to add lines to ~/.gitconfig

[alias]
st = status
ci = commit -v
[alias]
st = status
ci = commit
co = checkout
br = branch
unstage = reset HEAD --
last = log -1 HEAD
$ git config --global alias.unstage 'reset HEAD --'
$ git unstage fileA
$ git reset HEAD -- fileA
$ git config --global alias.last 'log -1 HEAD'
$ git last
commit 66938dae3329c7aebe598c2246a8e6af90d04646
Author:
Date: Tue Aug 26 19:48:51 2008 +0800
$ git config --global alias.visual '!gitk'

Written by

Web geek, Self-taught full-stack web developer, Learning Python, Laravel, Vuejs, UX/UI design, Nuclear Physicist PhD

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store