Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git disable pushing from local repository

I have a repository with some core code in it, and for each client I wish to clone it so I can do git pull everytime a client wants to upgrade to the newest functionality.

In the interest of not screwing things up and making changes that only one company sees, is there a way to only allow fetches on a local repository basis? I still want to be able to push changes to the core repo from my dev environment, but don't want production machines to be able to push.

like image 948
John Zumbrum Avatar asked Dec 04 '11 12:12

John Zumbrum


1 Answers

Specify a non-existing pushurl in the remote section of the clone-source repository (called origin) in the file .git/config. Example:

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = <url>
        pushurl = www.non-existing-url.com

Or if you don't like editing the config file of the repository you can type:

$ git config remote.origin.pushurl www.non-existing.com

When pushing you'll get an error message like:

$ git push
fatal: 'www.non-existing-url.com' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

Of course you'll need to edit the config file of each cloned repository.

like image 133
Paul Pladijs Avatar answered Oct 19 '22 03:10

Paul Pladijs