Is there any way to disable git pull
?
I'd like to either make it not work or not do anything, so that, when typing it by mistake, it won't cause me problems.
Since you are on OSX, you can write a function to check if you typed git pull.
If so, it will print a message, otherwise it will call git with the parameters.
Example:
git() { if [[ $@ == "pull" ]]; then command echo "Cannot pull!"; else command git "$@"; fi; }
Another way, if you've got root permissions, would be to:
$ sudo chmod 000 /usr/lib/git-core/git-pull
… or wherever the file is in your FS. Then:
$ git pull
fatal: cannot exec 'git-pull': Permission denied
$
Alternatively, you could replace it with something along the lines of
#!/bin/sh
echo "git-pull is disabled"
exit 1
I guess the problems you refer to are merge conflicts that may happen if your local branch diverged from the remote. In that case, try setting pull.ff
option in git config, like that:
[pull]
ff = only
This will tell git to only do fast-forward merges, which are guaranteed to not result in conflicts.
It is not directly possible in git, because git aliases are not allowed to override built-in commands.
However, you can create a bash function and alias that proxies your git command and modifies it. Steve Bennett gives a great example in this answer.
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