12

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.

John Zumbrum
  • 2,786
  • 8
  • 36
  • 60
  • I believe it depends on what you're using for hosting your git repository. Is it Github, your own git server or smth else? – KL-7 Dec 04 '11 at 12:20
  • possible duplicate of [How to make a git repository read-only?](http://stackoverflow.com/questions/1662205/how-to-make-a-git-repository-read-only) – Colin Hebert Dec 04 '11 at 12:21

2 Answers2

15

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.

Paul Pladijs
  • 18,628
  • 5
  • 28
  • 31
  • This looks like the info I was seeking. I just disassembled my repos as I'm reassembling them in a new way, but once I get them back together I'll test it out. – John Zumbrum Dec 06 '11 at 01:32
7

I find the remote command more useful so I don't have to mess with configs directly.

git remote set-url --push origin www.non-existing-url.com

should work as well

David A
  • 71
  • 1
  • 1