Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I disable git pull?

Tags:

git

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.

like image 895
Daniel C. Sobral Avatar asked Apr 08 '14 17:04

Daniel C. Sobral


4 Answers

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; }
like image 118
Bartlomiej Lewandowski Avatar answered Sep 17 '22 23:09

Bartlomiej Lewandowski


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
like image 31
Michal Rus Avatar answered Sep 20 '22 23:09

Michal Rus


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.

like image 44
Jan Warchoł Avatar answered Sep 21 '22 23:09

Jan Warchoł


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.

like image 27
Neall Avatar answered Sep 19 '22 23:09

Neall