Git command aliasingĀ allows us to improve upon our git workflow withĀ Git commands
Shortening Git commands
Instead of typing out a command line git status entirely, we could configure our command lines so that we can type justĀ git sĀ (orĀ git stĀ or whatever):
$ git config --global alias.s status
$ git s
The Git manual recommends other aliases:
$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
Combining Git commands
We could also combineĀ git addĀ andĀ git commitĀ into one command:
$ git config --global alias.add-commit '!git add -A && git commit'
$ git add-commit -m 'my commit message'
Combining the above two, we can do something like:
$ git config --global alias.ac add-commit
$ git ac -m "my commit message"
Also, we can generalize the format as:
$ git config --global alias.{alias} {command}
$ git {alias} [flags]
Other examples
Short forĀ git push origin master (pushing to the cloud):
$ git config --global alias.pom 'push origin master'
$ git pom
Short forĀ git checkout -b {branch-name}Ā (checking into a new branch):
$ git config --global alias.cob 'checkout -b'
$ git cob {new-branch-name}
Enjoy!
Jononews
The "ends" of web development