Ovi Faur
Ovi Faur

Reputation: 528

Git alias replace GIT

This is just for the fun of it given the star wars hype. Is it possible to alias the actual GIT command with something else like "force"? So when you do a git push you actually write force push or git pull you write force pull?

Upvotes: 1

Views: 85

Answers (1)

mattmilten
mattmilten

Reputation: 6726

Linux/MacOS solution: Put this into your .bashrc to alias git with force:

complete -o bashdefault -o default -o nospace -F _git force 2>/dev/null \
    || complete -o default -o nospace -F _git force
alias force='git'

EDIT: The first command makes all the usual auto completion magic work with the new alias. Without it, tab-completion would not work, because the system doesn't recognize force to be a git command until it's executed.

Upvotes: 4

Related Questions