DEV Community

Cover image for How I optimized my use of git
Carlos Gándara
Carlos Gándara

Posted on • Edited on

3 3

How I optimized my use of git

Small details can make a huge difference -- Somebody at some point, I guess

Add an alias in your shell to use g for git. You will save a lot of typing at the end of the day.

# in your .bashrc or equivalent
alias g='git'
Enter fullscreen mode Exit fullscreen mode

So now you will do g pull instead of the extremely verbose git pull.

As bonus points, some bits from my Git configuration. All the following is in ~/.gitconfig:

  • Using a global .gitignore with the usual suspects (.DS_Store, Thumbs.db, etc.)
[core]
excludesfile = ~/.gitignore-global
Enter fullscreen mode Exit fullscreen mode
  • I always want to pull --rebase, so I have it enabled by default:
[pull]
    rebase = true
Enter fullscreen mode Exit fullscreen mode
  • Git comes with a pretty much unknown autocorrect feature. If you mistype some command, it will execute it after some configured time. Enable it with the tenths of a second to do so:
[help]
    autocorrect = 5 
Enter fullscreen mode Exit fullscreen mode
  • And my current list of git aliases, in case it is inspiring to somebody. They print the actual command to do not forget what I am doing:
[alias]
    s        = !echo 'git status -s' && git status -s
    aa       = !echo 'git add .' && git add .
    c        = !echo 'git commit -m' && git commit -m
    co       = !echo 'git checkout' && git checkout
    amend    = !echo 'git commit --amend --no-edit' && commit --amend --no-edit
    amendall = !echo 'git add . && git commit --amend --no-edit' && git add . && git commit --amend --no-edit
    syncwith = !echo 'git pull --rebase origin' && git pull --rebase origin
    lg       = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit
Enter fullscreen mode Exit fullscreen mode

Final advice: try to optimize what you do over and over again during the day.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay