A New Lease on Git

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!

A New Lease on Git

Leave a Reply

Your email address will not be published. Required fields are marked *