<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hemant Mishra</title>
    <description>The latest articles on DEV Community by Hemant Mishra (@hmnt39).</description>
    <link>https://dev.to/hmnt39</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F251237%2Fce0d7989-b934-4236-a18a-6a0791bb7e8d.jpeg</url>
      <title>DEV Community: Hemant Mishra</title>
      <link>https://dev.to/hmnt39</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hmnt39"/>
    <language>en</language>
    <item>
      <title>Setup Local Git Server on your system</title>
      <dc:creator>Hemant Mishra</dc:creator>
      <pubDate>Sat, 06 Mar 2021 17:55:02 +0000</pubDate>
      <link>https://dev.to/hmnt39/setup-local-git-server-on-your-system-195</link>
      <guid>https://dev.to/hmnt39/setup-local-git-server-on-your-system-195</guid>
      <description>&lt;p&gt;Have you ever wonder how Github, Bitbucket are storing our git based project? Can we do these on our system? Let's find out.&lt;/p&gt;

&lt;p&gt;So, the answer is Yes, we can create a local server on our system which behave exactly like popular version control software. Before starting I am assuming you know what Git is and used for.&lt;/p&gt;

&lt;h1&gt;
  
  
  Create a server repository
&lt;/h1&gt;

&lt;p&gt;Whenever you clone or initialize a git repository, there is two things which can be seen one is .git folder and other is your working area.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VJn7uZ3B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5iaqqhiqgbmj53jql84x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VJn7uZ3B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5iaqqhiqgbmj53jql84x.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.git folder is the index folder which stores the metadata of working tree, config files, hooks, head refs etc. and other is the actual working area where you can see your local files.&lt;br&gt;
To know more about .git folder. Follow this &lt;a href="https://www.greengeeks.in/tutorials/article/git-repository-structure/"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As, we are creating server so we don't need a working area. Can we do this? Of course.&lt;br&gt;
First we create a server repository named &lt;strong&gt;server.git&lt;/strong&gt;, you can name anything.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir server.git
cd server.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, initialize this repository with Git. But wait there is a change in the command. We have to use --bare argument with init command. What it does? It create a bare repository without any working directory. Make sense&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init --bare
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--disBicWr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dot1j7q5djmjmh2kta8x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--disBicWr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dot1j7q5djmjmh2kta8x.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As soon as you initialized the repo, you got the directory url which you can use in different directory as remote url. Isn't it so easy?&lt;/p&gt;

&lt;h1&gt;
  
  
  Create a Client repository
&lt;/h1&gt;

&lt;p&gt;Now it's time to create a client repository and check whether our setup is working or not.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir client &amp;amp;&amp;amp; cd client
git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, add our server as a remote to the repository.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin /&amp;lt;path&amp;gt;/server.git/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--43HY_lfc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zo04t7ctpfhbi533zhl2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--43HY_lfc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zo04t7ctpfhbi533zhl2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's check whether we're able to push our changes to the remote. Create a file with some content and add &amp;amp; commit.&lt;br&gt;
Now push that file to the remote branch.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_3J0nNyf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qy19smk7qyi02xfgybdw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_3J0nNyf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qy19smk7qyi02xfgybdw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last step, can we clone this repository or download our changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone &amp;lt;path_to_your_local_server&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2NUYN6pD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fo0b42ah3j62rxrjqqjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2NUYN6pD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fo0b42ah3j62rxrjqqjv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Voila! It works&lt;/p&gt;

&lt;h1&gt;
  
  
  What to do next?
&lt;/h1&gt;

&lt;p&gt;Of course, you can host your local server repository over the internet using nginx or Apache. There are lot of things to do with Git. Comment your way to host local setup over internet.&lt;/p&gt;

</description>
      <category>git</category>
      <category>linux</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
