This is a collection of aliases that I like to use to optimize my git usage a little. I mostly use command line Git, so this makes my life a lot easier.
I recommend that you do not copy these directly into the .gitconfig for your repository. While you certainly could, I instead recommend cloning this repository somewhere and adding it to the git repo(s) you want to use the aliases in.
To add it to a specific repo, run this command from within that repo.
git config include.path "path\to\gitconfig"
To add it to all repos, run this command anywhere on the command line.
git config --global include.path "path\to\gitconfig"
In order to update your list of aliases, simply run git pull
inside of this repo on your local machine. All of your git repos that utilize these aliases will now be able to use the new ones.
git co main
Checks out a specific branch or commit. Short-hand for git checkout <branch|commit>
.
git currentbranch
Display the name of the currently checked out branch.
git comp --rebase
Checks out the main branch and executes a pull. If any pull_arguments
are specified, these will be proxied to the git pull
command. If main is not a valid branch, it falls back to using master (legacy standard).
git graph
Displays the history of the repo in a prettyfied format.
git f
Short-hand for git fetch
git feature JIRA-1234
Creates and checks out a new feature branch with the name feature/work_item
. Defaults to tmp
if no work_item
argument is specified.
git rib main
Begins the process of interactive rebasing the current branch against the branch_name
argument. Defaults to main
if no branch_name
argument is specified.
git show-diff abc123
Shows the changes introduced by the commit specified by the commit_hash
argument. Defaults to HEAD
if no commit_hash
argument is specified.
git spp --rebase
Stashes local changes, pulls, then pops stash to re-apply the stashed changes. The git pull
command can be passed arguments using the pull_arguments
specified after git spp
git find-withered-branches
Prints the remote branches with the 10 oldest heads. Can be used to find old, "withered" branches that should be deleted from the remote.
git ahead-behind origin/main
Shows commits 'ahead' and 'behind' of the current branch and the provided remote branch. Defaults to origin/main if not provided, and automatically infers the current branch.
git soft-clean
Attempts to clean a project without removing commonly locally changed files. Currently excludes web.config, appsettings.json, app-config.json, and app.config
git delete-branches [pattern]
Deletes all local branches that match the pattern. Pattern follows all grep
rules.
git l
Runs git log --oneline --graph
git compare-branch origin/main
List all commits on this branch but not on the target branch (Defaults to your default branch)
git s
Runs a simplified (compact) status command. Output looks like this:
## master...origin/master [behind 1]
M README.md
M gitconfig