# Repositories and git

**URL:** <https://discourse.chef.io/t/repositories-and-git/1927>\
**Category:** Chef Infra (archive)\
**Created:** [July 18, 2011, 8:36pm UTC](https://discourse.chef.io/t/repositories-and-git/1927 "2011-07-18T20:36:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oliver\_Beattie](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/oliver_beattie/32/809_2.png) [@Oliver\_Beattie](https://discourse.chef.io/u/Oliver_Beattie)\
**Post date:** [July 18, 2011, 8:36pm UTC](https://discourse.chef.io/t/repositories-and-git/1927/1 "2011-07-18T20:36:29Z")

</div>

Hi there,

This may seem like a really basic question, and I feel I’ve probably missed  
some really elemental “aha moment” that most people get within 10 seconds,  
but I’m struggling to understand how repositories work with git.

For instance, is it possible to clone the repository and add cookbooks to it  
locally? When I try it (via use of Knife) I just get an error saying  
/srv/chef/{something} doesn’t exist. I’m assuming to get the benefits of a  
(D)VCS this must be possible?

Thanks (and apologies if I’m being terribly dense).

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [July 18, 2011, 8:46pm UTC](https://discourse.chef.io/t/repositories-and-git/1927/2 "2011-07-18T20:46:37Z")

</div>

Chef never uses git itself, you upload the cookbooks and other data to the chef-server via knife and clients interface with it from there (or, if you use solo, it just looks in a local folder of your choosing). If you want to use git to version things you are encouraged to (or hg, subversion, etc), but it isn't tied in to Chef itself.

--Noah

On Jul 18, 2011, at 1:36 PM, Oliver Beattie wrote:

> Hi there,
> 
> This may seem like a really basic question, and I feel I've probably missed some really elemental "aha moment" that most people get within 10 seconds, but I'm struggling to understand how repositories work with git.
> 
> For instance, is it possible to clone the repository and add cookbooks to it locally? When I try it (via use of Knife) I just get an error saying /srv/chef/{something} doesn't exist. I'm assuming to get the benefits of a (D)VCS this must be possible?
> 
> Thanks (and apologies if I'm being terribly dense).

---

<div class="post-metadata">

**Author:** ![jhulten](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jhulten/32/804_2.png) [@jhulten](https://discourse.chef.io/u/jhulten)\
**Post date:** [July 18, 2011, 9:01pm UTC](https://discourse.chef.io/t/repositories-and-git/1927/3 "2011-07-18T21:01:38Z")

</div>

In think the only time Git is invoked is when you use knife cookbook site vendor . It's really only a shortcut for people that use Git since you could do all those steps by hand...

Sent from my iPad

On Jul 18, 2011, at 1:46 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:

> Chef never uses git itself, you upload the cookbooks and other data to the chef-server via knife and clients interface with it from there (or, if you use solo, it just looks in a local folder of your choosing). If you want to use git to version things you are encouraged to (or hg, subversion, etc), but it isn't tied in to Chef itself.
> 
> --Noah
> 
> On Jul 18, 2011, at 1:36 PM, Oliver Beattie wrote:
> 
> > Hi there,
> > 
> > This may seem like a really basic question, and I feel I've probably missed some really elemental "aha moment" that most people get within 10 seconds, but I'm struggling to understand how repositories work with git.
> > 
> > For instance, is it possible to clone the repository and add cookbooks to it locally? When I try it (via use of Knife) I just get an error saying /srv/chef/{something} doesn't exist. I'm assuming to get the benefits of a (D)VCS this must be possible?
> > 
> > Thanks (and apologies if I'm being terribly dense).

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [July 18, 2011, 9:02pm UTC](https://discourse.chef.io/t/repositories-and-git/1927/4 "2011-07-18T21:02:52Z")

</div>

And it should only do that if it detects it is in a git repo anyway.

--Noah

On Jul 18, 2011, at 2:01 PM, Jeffrey Hulten wrote:

> In think the only time Git is invoked is when you use knife cookbook site vendor . It's really only a shortcut for people that use Git since you could do all those steps by hand...
> 
> Sent from my iPad
> 
> On Jul 18, 2011, at 1:46 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:
> 
> > Chef never uses git itself, you upload the cookbooks and other data to the chef-server via knife and clients interface with it from there (or, if you use solo, it just looks in a local folder of your choosing). If you want to use git to version things you are encouraged to (or hg, subversion, etc), but it isn't tied in to Chef itself.
> > 
> > --Noah
> > 
> > On Jul 18, 2011, at 1:36 PM, Oliver Beattie wrote:
> > 
> > > Hi there,
> > > 
> > > This may seem like a really basic question, and I feel I've probably missed some really elemental "aha moment" that most people get within 10 seconds, but I'm struggling to understand how repositories work with git.
> > > 
> > > For instance, is it possible to clone the repository and add cookbooks to it locally? When I try it (via use of Knife) I just get an error saying /srv/chef/{something} doesn't exist. I'm assuming to get the benefits of a (D)VCS this must be possible?
> > > 
> > > Thanks (and apologies if I'm being terribly dense).

---

<div class="post-metadata">

**Author:** ![Oliver\_Beattie](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/oliver_beattie/32/809_2.png) [@Oliver\_Beattie](https://discourse.chef.io/u/Oliver_Beattie)\
**Post date:** [July 18, 2011, 9:15pm UTC](https://discourse.chef.io/t/repositories-and-git/1927/5 "2011-07-18T21:15:00Z")

</div>

So, if I understand right, if I want to install a cookbook to my repository,  
I can only do this on the server machine itself, right?

On 18 July 2011 22:02, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:

> And it should only do that if it detects it is in a git repo anyway.
> 
> --Noah
> 
> On Jul 18, 2011, at 2:01 PM, Jeffrey Hulten wrote:
> 
> > In think the only time Git is invoked is when you use knife cookbook site  
> > vendor . It's really only a shortcut for people that use Git since you  
> > could do all those steps by hand...
> > 
> > Sent from my iPad
> > 
> > On Jul 18, 2011, at 1:46 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net)  
> > wrote:
> > 
> > > Chef never uses git itself, you upload the cookbooks and other data to  
> > > the chef-server via knife and clients interface with it from there (or, if  
> > > you use solo, it just looks in a local folder of your choosing). If you want  
> > > to use git to version things you are encouraged to (or hg, subversion, etc),  
> > > but it isn't tied in to Chef itself.
> > > 
> > > --Noah
> > > 
> > > On Jul 18, 2011, at 1:36 PM, Oliver Beattie wrote:
> > > 
> > > > Hi there,
> > > > 
> > > > This may seem like a really basic question, and I feel I've probably  
> > > > missed some really elemental "aha moment" that most people get within 10  
> > > > seconds, but I'm struggling to understand how repositories work with git.
> > > > 
> > > > For instance, is it possible to clone the repository and add cookbooks  
> > > > to it locally? When I try it (via use of Knife) I just get an error saying  
> > > > /srv/chef/{something} doesn't exist. I'm assuming to get the benefits of a  
> > > > (D)VCS this must be possible?
> > > > 
> > > > Thanks (and apologies if I'm being terribly dense).

---

<div class="post-metadata">

**Author:** ![Jeffrey\_E\_Sussna](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Jeffrey\_E\_Sussna](https://discourse.chef.io/u/Jeffrey_E_Sussna)\
**Post date:** [July 18, 2011, 9:17pm UTC](https://discourse.chef.io/t/repositories-and-git/1927/6 "2011-07-18T21:17:05Z")

</div>

I think this is one of the reasons Chef is confusing to approach for  
newbies. Yes, the Getting Started wiki page tells you that git is optional.  
The problem is that git has been added to the already large list of  
tools/concepts you need consider, even if only to decide to ignore it.

Jeff

On Mon, Jul 18, 2011 at 3:46 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net)wrote:

> Chef never uses git itself, you upload the cookbooks and other data to the  
> chef-server via knife and clients interface with it from there (or, if you  
> use solo, it just looks in a local folder of your choosing). If you want to  
> use git to version things you are encouraged to (or hg, subversion, etc),  
> but it isn't tied in to Chef itself.
> 
> --Noah
> 
> On Jul 18, 2011, at 1:36 PM, Oliver Beattie wrote:
> 
> > Hi there,
> > 
> > This may seem like a really basic question, and I feel I've probably  
> > missed some really elemental "aha moment" that most people get within 10  
> > seconds, but I'm struggling to understand how repositories work with git.
> > 
> > For instance, is it possible to clone the repository and add cookbooks to  
> > it locally? When I try it (via use of Knife) I just get an error saying  
> > /srv/chef/{something} doesn't exist. I'm assuming to get the benefits of a  
> > (D)VCS this must be possible?
> > 
> > Thanks (and apologies if I'm being terribly dense).

---

<div class="post-metadata">

**Author:** ![KC\_Braunschweig](https://avatars.discourse-cdn.com/v4/letter/k/ea5d25/32.png) [@KC\_Braunschweig](https://discourse.chef.io/u/KC_Braunschweig)\
**Post date:** [July 18, 2011, 9:21pm UTC](https://discourse.chef.io/t/repositories-and-git/1927/7 "2011-07-18T21:21:24Z")

</div>

On Mon, Jul 18, 2011 at 2:15 PM, Oliver Beattie [oliver@luckyvoice.com](mailto:oliver@luckyvoice.com) wrote:

> So, if I understand right, if I want to install a cookbook to my repository,  
> I can only do this on the server machine itself, right?

No, you wouldn't work with your chef-repo on your chef server.  
Instead, check it out and work with it on your own local workstation  
and then use knife and the chef-server API to upload cookbooks to the  
chef server (knife cookbook upload \<cookbook\_name\>). Maybe if you get  
fancy, you'll build an automated process to push your changes from  
revision control onto the chef server, but you always use the API.  
Unlike Puppet (at least when I last used it) the server itself never  
reads from a local checkout of the repo but expects you to send it  
things via the API that it caches in its own way.

KC

---

<div class="post-metadata">

**Author:** ![Nuo\_Yan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/nuo_yan/32/633_2.png) [@Nuo\_Yan](https://discourse.chef.io/u/Nuo_Yan)\
**Post date:** [July 18, 2011, 9:22pm UTC](https://discourse.chef.io/t/repositories-and-git/1927/8 "2011-07-18T21:22:04Z")

</div>

If you want the cookbook to be used by the chef-client run on the server,  
from your workstation, you do "knife cookbook upload COOKBOOKNAME" in your  
chef repo to upload the cookbook. Of course on your workstation you need to  
specify in the config file (knife.rb) about where you store those cookbooks  
locally.

- Nuo

On Mon, Jul 18, 2011 at 2:15 PM, Oliver Beattie [oliver@luckyvoice.com](mailto:oliver@luckyvoice.com)wrote:

> So, if I understand right, if I want to install a cookbook to my  
> repository, I can only do this on the server machine itself, right?
> 
> On 18 July 2011 22:02, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:
> 
> > And it should only do that if it detects it is in a git repo anyway.
> > 
> > --Noah
> > 
> > On Jul 18, 2011, at 2:01 PM, Jeffrey Hulten wrote:
> > 
> > > In think the only time Git is invoked is when you use knife cookbook  
> > > site vendor . It's really only a shortcut for people that use Git  
> > > since you could do all those steps by hand...
> > > 
> > > Sent from my iPad
> > > 
> > > On Jul 18, 2011, at 1:46 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net)  
> > > wrote:
> > > 
> > > > Chef never uses git itself, you upload the cookbooks and other data to  
> > > > the chef-server via knife and clients interface with it from there (or, if  
> > > > you use solo, it just looks in a local folder of your choosing). If you want  
> > > > to use git to version things you are encouraged to (or hg, subversion, etc),  
> > > > but it isn't tied in to Chef itself.
> > > > 
> > > > --Noah
> > > > 
> > > > On Jul 18, 2011, at 1:36 PM, Oliver Beattie wrote:
> > > > 
> > > > > Hi there,
> > > > > 
> > > > > This may seem like a really basic question, and I feel I've probably  
> > > > > missed some really elemental "aha moment" that most people get within 10  
> > > > > seconds, but I'm struggling to understand how repositories work with git.
> > > > > 
> > > > > For instance, is it possible to clone the repository and add cookbooks  
> > > > > to it locally? When I try it (via use of Knife) I just get an error saying  
> > > > > /srv/chef/{something} doesn't exist. I'm assuming to get the benefits of a  
> > > > > (D)VCS this must be possible?
> > > > > 
> > > > > Thanks (and apologies if I'm being terribly dense).

---

<div class="post-metadata">

**Author:** ![Oliver\_Beattie](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/oliver_beattie/32/809_2.png) [@Oliver\_Beattie](https://discourse.chef.io/u/Oliver_Beattie)\
**Post date:** [July 19, 2011, 10:44am UTC](https://discourse.chef.io/t/repositories-and-git/1927/9 "2011-07-19T10:44:42Z")

</div>

Okay, this explains things a lot better.

So, consider the case I want to add a community cookbook to my server. How  
would I go about doing that?

On 18 July 2011 22:21, KC Braunschweig [kcbraunschweig@gmail.com](mailto:kcbraunschweig@gmail.com) wrote:

> On Mon, Jul 18, 2011 at 2:15 PM, Oliver Beattie [oliver@luckyvoice.com](mailto:oliver@luckyvoice.com)  
> wrote:
> 
> > So, if I understand right, if I want to install a cookbook to my  
> > repository,  
> > I can only do this on the server machine itself, right?
> 
> No, you wouldn't work with your chef-repo on your chef server.  
> Instead, check it out and work with it on your own local workstation  
> and then use knife and the chef-server API to upload cookbooks to the  
> chef server (knife cookbook upload \<cookbook\_name\>). Maybe if you get  
> fancy, you'll build an automated process to push your changes from  
> revision control onto the chef server, but you always use the API.  
> Unlike Puppet (at least when I last used it) the server itself never  
> reads from a local checkout of the repo but expects you to send it  
> things via the API that it caches in its own way.
> 
> KC

---

<div class="post-metadata">

**Author:** ![Joshua\_Timberman](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshua_timberman/32/424_2.png) [@Joshua\_Timberman](https://discourse.chef.io/u/Joshua_Timberman)\
**Post date:** [July 20, 2011, 6:10am UTC](https://discourse.chef.io/t/repositories-and-git/1927/10 "2011-07-20T06:10:35Z")

</div>

On Tue, Jul 19, 2011 at 4:44 AM, Oliver Beattie [oliver@luckyvoice.com](mailto:oliver@luckyvoice.com) wrote:

> Okay, this explains things a lot better.  
> So, consider the case I want to add a community cookbook to my server. How  
> would I go about doing that?

If your local repository is git:

knife cookbook site install COOKBOOK  
knife cookbook upload COOKBOOK

This will install the cookbook in the chef-repo, handling all the cool  
branching and tagging that you can do with git, then upload the  
cookbook to the server. Somewhere in there you should probably read  
the code to see what its going to do on your systems.

If you local repository is not git, then:

knife cookbook site download COOKBOOK  
tar -zxvf COOKBOOK.tar.gz -C cookbooks  
[ use your version control system to commit to the repo, do any  
branch/merge/tag work etc ]  
knife cookbook upload COOKBOOK

--  
Opscode, Inc  
Joshua Timberman, Director of Training and Services  
IRC, Skype, Twitter, Github: jtimberman
