Git aliases and commands
Git Tools is a collection of Git aliases and convenience commands that I use in my development workflow. I've packed them up to make them easy to share and keep up-to-date across my various development environments. You're welcome to use them and I'd love contributions.
-
Clone the repository:
mkdir -p ~/Projects cd ~/Projects git clone git@github.com:jbmorley/git-tools.git
-
Update the submodules:
git submodule update --init
-
Include the Git Tools configuration file in your local Git configuration. For example, if you've cloned this repository to
~/Projects/git-tools
, then you would add the following section to yout~/.gitconfig
:[include] path = ~/Projects/git-tools/config
git gt-update
Git Tools adds the following additional git commands, many of which are simply shorter forms to avoid the need to type too much:
br
– alias forbranch
git branch
ci
– alias forcommit
git commit
co
– alias forcheckout
git checkout
d
– alias fordiff
git diff
dc
– show the cached changesgit diff --cached
del
– interactive delete branchdt
– alias fordifftool
git difftool
gt-install
– install Git Tools dependenciesgt-install-directory
– echo Git Tools install directorygt-update
– update Git Tools installationlist-aliases
– list all aliasesgit config --get-regexp ^alias
p
– pushgit push
pf
– force push with leasegit push --force-with-lease
pr
– create a new PR on GitHub (requires the GitHub CLI to be installed)gh pr create -w
s
– alias forstatus
git status
sha
– alias forrev-parse HEAD
git rev-parse HEAD
sl
sla
st
– alias forstatus
git status
unstage
– unstage the current changesgit reset HEAD --
up
– fetch and rebase ontoorigin/main
git fetch origin -p git rebase origin/main --autostash git submodule update --init --recursive
xbranch <new branch>
orxb <new branch>
– move the current uncommitted changes to a new branch by stashing, checking out main, updating main, and checking out the new branch, and applying the stashed changes.