I use git up
in order to avoid merge bubbles, but sometimes I accidentally issue a git pull
.
What is the best way to systematically replace a git pull
with a git up
?
As stated in the git-config documentation, it is not possible to alias an existing git command.
We can use a bash function that asks you to confirm that you want to actually use the git pull
command, and also offers you the opportunity to use git up
instead:
function git() {
if [[ $@ == "pull" ]]; then
read -p "Do you want to [p]ull, [u]p or [a]bort? " yn
case $yn in
[Pp]* ) command git pull;;
[Uu]* ) command git up;;
* ) echo "bye";;
esac
else
command git "$@"
fi
}
$ git pull
Do you want to [p]ull, [u]p or [a]bort? u
Fetching origin
master up to date
$ git pull
Do you want to [p]ull, [u]p or [a]bort? p
Already up-to-date.
$ git pull
Do you want to [p]ull, [u]p or [a]bort? a
bye
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With