<?xml version="1.0" encoding='utf-8'?>
<?xml-stylesheet type="text/xsl" href="https://nozaki.me/roller/roller-ui/styles/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom">
    <title type="html">Kohei Nozaki&apos;s blog</title>
    <subtitle type="html">Notes of my experiments</subtitle>
    <id>https://nozaki.me/roller/kyle/feed/entries/atom</id>
            <link rel="self" type="application/atom+xml" href="https://nozaki.me/roller/kyle/feed/entries/atom?cat=Git" />
        <link rel="alternate" type="text/html" href="https://nozaki.me/roller/kyle/" />
        <updated>2024-05-01T08:28:13+00:00</updated>
    <generator uri="http://roller.apache.org" version="5.2.0">Apache Roller</generator>
        <entry>
        <id>https://nozaki.me/roller/kyle/entry/creating-a-shared-git-repository</id>
        <title type="html">Creating a shared git repository on local filesystem</title>
        <author><name>Kohei Nozaki</name></author>
        <link rel="alternate" type="text/html" href="https://nozaki.me/roller/kyle/entry/creating-a-shared-git-repository"/>
        <published>2015-03-01T08:04:52+00:00</published>
        <updated>2015-03-04T12:12:59+00:00</updated> 
        <category term="Git" label="Git" />
        <category term="git" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Tested with OS X 10.9.5.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_requirement&quot;&gt;Requirement&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;There are 2 users (&lt;code&gt;kyle&lt;/code&gt; and &lt;code&gt;jenkins&lt;/code&gt;). they want to have a shared git repository named &lt;code&gt;trader&lt;/code&gt; on local filesystem. both of them can push changes into the repository.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_recipe&quot;&gt;Recipe&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;olist arabic&quot;&gt;
&lt;ol class=&quot;arabic&quot;&gt;
&lt;li&gt;
&lt;p&gt;Create a group named &lt;code&gt;trader&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ sudo dseditgroup -o create trader&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Let join &lt;code&gt;kyle&lt;/code&gt; nad &lt;code&gt;jenkins&lt;/code&gt; into the group &lt;code&gt;trader&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ sudo dseditgroup -o edit -a kyle -t user trader
$ sudo dseditgroup -o edit -a jenkins -t user trader&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a bare repository&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ cd /Users/Shared
$ mkdir trader.git
$ cd trader.git
$ git init --bare --shared&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Change owning group of &lt;code&gt;trader.git&lt;/code&gt; to &lt;code&gt;trader&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ cd ../
$ chown -R :trader trader.git&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make the repository writable by users in &lt;code&gt;trader&lt;/code&gt; group&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ chmod -R g+w trader.git&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_testing&quot;&gt;Testing&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;olist arabic&quot;&gt;
&lt;ol class=&quot;arabic&quot;&gt;
&lt;li&gt;
&lt;p&gt;Clone the repository&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ git clone /Users/Shared/trader.git&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make first commit by &lt;code&gt;kyle&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ cd trader
$ echo &apos;hi there&apos; &amp;gt; hi.txt
$ git add hi.txt
$ git commit -m &apos;first commit from kyle&apos;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Push to the parent repository&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ git push origin master&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Switch to user &lt;code&gt;jenkins&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ sudo su - jenkins&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Clone the repository&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ git clone /Users/Shared/trader.git&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make first commit by &lt;code&gt;jenkins&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ cd trader
$ echo hi there from jenkins &amp;gt;&amp;gt; hi.txt
$ git add hi.txt
$ git commit -m &apos;first commit from jenkins&apos;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Push to the parent repository&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ git push origin master&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Pull the change made by &lt;code&gt;jenkins&lt;/code&gt; from user &lt;code&gt;kyle&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ whoami
kyle
$ cat hi.txt
hi there
$ git pull origin master
$ cat hi.txt
hi there
hi there from jenkins&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content>
    </entry>
</feed>

