DEV Community

Cover image for Setup aliases and shortcuts for git commands
Viral Patel
Viral Patel

Posted on

3 1

Setup aliases and shortcuts for git commands

Here is how you setup aliases and shortcuts for git commands. Edit .gitconfig file in your $HOME directory.

[alias]
  co = checkout
  ci = commit
  st = status
  br = branch
  hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
  type = cat-file -t
  dump = cat-file -p

Refer to the branch you've checked out when you use git push and/or git pull

[push]
  default = current

Here are some more goodies in your aliases list. Thank me later 😎

[alias]
  # Adds and commits files with a single command
  add-commit = !git add -A && git commit

  # Delete all local branches but master and the current one, only if they are fully merged with master.
  br-delete-useless = "!f(){\git branch | grep -v "master" | grep -v ^* | xargs git branch -d;\}; f"

  # Delete all local branches but master and the current one.
  br-delete-useless-force = "!f(){\git branch | grep -v "master" | grep -v ^* | xargs git branch -D;\}; f"

This blog was originally published on my personal blog Viral Patel

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay