<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://nozaki.me/roller/roller-ui/styles/rss.xsl" media="screen"?><rss version="2.0" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
  <title>Kohei Nozaki&apos;s blog</title>
  <link>https://nozaki.me/roller/kyle/</link>
      <atom:link rel="self" type="application/rss+xml" href="https://nozaki.me/roller/kyle/feed/entries/rss?cat=Git" />
    <description>Notes of my experiments</description>
  <language>en-us</language>
  <copyright>Copyright 2024</copyright>
  <lastBuildDate>Wed, 1 May 2024 08:28:13 +0000</lastBuildDate>
  <generator>Apache Roller 5.2.0</generator>
        <item>
    <guid isPermaLink="true">https://nozaki.me/roller/kyle/entry/creating-a-shared-git-repository</guid>
    <title>Creating a shared git repository on local filesystem</title>
    <dc:creator>Kohei Nozaki</dc:creator>
    <link>https://nozaki.me/roller/kyle/entry/creating-a-shared-git-repository</link>
        <pubDate>Sun, 1 Mar 2015 08:04:52 +0000</pubDate>
    <category>Git</category>
    <category>git</category>
            <description>&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;</description>          </item>
  </channel>
</rss>