Creating a Shared Repository Between Two Local Machines - Perficient Blogs
Blog
  • Topics
  • Industries
  • Partners

Explore

Topics

Industries

Partners

Creating a Shared Repository Between Two Local Machines

GIT is one of the most sophisticated version control systems, and it’s widely used by various organisations. With the help of GitHub, a web-based GIT repository hosting service can be accomplished. In some of the projects involving fewer resources, which requires a common repository in a local machine, GIT enables us to create a shared repository in a local machine. This could be achieved in two ways:

  • Making the shared repository public, among the developers who work on the same project.
  • Establishing SSH link between machines that works on the same project.

Here, I’ll cover the steps involved in creating a shared public repository between two local machines. Initially, we create a bare shared repository and make it as a remote origin. Bare repository is basically meant to be a shared repository; hence we clone the repository to commit the changes to the bare repository. We create another clone to check out the updated changes.

CREATING BARE REPOSITORY:

  • Create a directory, in GIT bash.

image1

  • Create a bare repository and create a remote origin.

image2

  • A bare repository has now been created. We make the bare repository public to those machine connected within the same network.

image3

image4

  • Make the share the directory directly to the desired machine’s IP address. Give the read/ write access, to the shared location.

     CLONE THE BARE REPOSITORY FROM ANOTHER MACHINE:

Clone the bare repository. No commits could be made directly to the bare repository. In order to push your changes you will have to clone the bare repository.image5

GIT clone remote repository URL

  •  Remote repository URL should be in the below format.git clone file:////<host>/<share>/<path>If the repository needs to be cloned from another machine the host name should be the IP address of the bare repository machine. Otherwise the actual file path of the bare repository machine should be mentionedEx.-git clone file:////main/code/project-repository-git clone file:////192.168.10.51/code/project-repository

    Now myLocalRepo has the clone of the bare repository. Let’s create a sample.txt file and push the changes to the master repository

image6

The Sample.txt has been checked into the master repository. Let’s create a sampleRepo and clone the master repository and pull the changes through GIT pull origin master.

image7

The above steps explain the procedure for creating a shared repository with a local machine through its IP address, belonging to the same network. Though this has some disadvantages, as the IP address changes frequently, it can still be applied where there are less resources and a small work environment. In order to enhance the security and make it less dependent on the machine’s IP network, SSH connection could be established between two machines exchanging the private key.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up

Categories