A new lease on git

Published: Aug 25, 2017 by luxagen

For some time now I’ve been using the pushf alias suggested here to give me an easy way to safely force-push branches in Git, but a persistent annoyance has been that the alias doesn’t provide the same branch-name autocompletion as the inbuilt push command.

Today I set out to solve that problem and quickly came across this solution. Putting it all together, here’s how to define a pushf alias for Git with autocompletion under bash:

  • run git config --global alias.pushf "push --force-with-lease"
  • edit ~/.bashrc and append: _git_pushf() { _git_branch ; }

That’s it!

Share