8

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.

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681

4 Answers4

8

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; }
Bartlomiej Lewandowski
  • 10,771
  • 14
  • 44
  • 75
3

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
Michal Rus
  • 1,796
  • 2
  • 18
  • 27
3

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.

Jan Warchoł
  • 1,063
  • 1
  • 9
  • 22
1

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.

Community
  • 1
  • 1
Neall
  • 26,428
  • 5
  • 49
  • 48