Skip to content

Setup your own git version control system on Windows 10

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

If you are a regular user of git, you must know that everything is about repositories and operations on these. Repositories are first and foremost directories which main purpose is to contain data or files that will be shared by many people.

This article is to show up how you can set up your own server without using Github or Gitlab. For this tutorial, we are going to do it on windows 10.
Let’s jump in !

Steps to follow

Let us assume that we have two machines based in the same network. The server named MSERVER and a client machine named MCLIENT.

Operations on MSERVER

# 1

Go to Git — Downloading Package (git-scm.com) to download the current version of Git. Install it normally on your Windows 10 machine.

For your first installation you must globally configure your git credentials on your computer in order to be able to make authenticated changes to all future projects you will work on.

Open a powershell and tap the following commands.

git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"

# 2

After getting Git installed, create a new directory on MSERVER.
Let’s give it the name :  git-server.

Then open a powershell or Windows command prompt on your machine and go to the root of git-server directory.

Tap the following to initialize a new git repository on MSERVER :

git init myRepoName -- bare

This command can be explained as follows :

It Initializes an empty Git repository, but omit the working directory. Shared repositories should always be created with the --bare flag (see discussion below). Conventionally, repositories initialized with the --bare flag end in .git. For example, the bare version of a repository called my-project should be stored in a directory called my-project.git.

https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-init

# 3

Come back to file explorer and make a right click on git-server directory, select Properties → Sharing → Share Button.
A modal will then appear, click on the dropdown annd choose EveryOne and click on Add button at the right. After doing so, change this group rights on his right side by selecting Read/Write and Click on Share.
You will get a following screen with a similar information to this.

On this image, you can notice “DESKTOP-IV3TUO8”. That is the name of the server machine in my network. So replace it accordingly with your server name.

Operations on MCLIENT

# 1

Create a directory name git-client  on the client machine. This will allow us working on the previous repository created on the server machine.

Now open a powershell prompt and go to the root of git-client directory and clone myRepoName  from git-server.

You can do that using the typical following command :

git clone \\NameOfServerMachine\git-server\myRepoName

// On my side, I used exactly the following command :
git clone \\DESKTOP-IV3TUO8\git-server\myRepoName

// With "DESKTOP-IV3TUO8" as my server machine name.

As you can see the clone operation was successful.

# 2

Now let’s create a text file into our clone repository that is located in git-client directory and push changes to the repository on git-server.

  • Create a text file in the repo through powershell:
// Create a new text file being placed in the repo
New-Item test.txt


// Add a content to the new file
Set-Content test.txt 'This is a test'
  • Add the new file to git :
git add test.txt
  • Named the changes made to git :
git commit -m "test.txt added"
  • Push the changes to the repository on the server :
git push origin master

These are the basics operations you need to know if you ever mind managing up your own version control system using Git in a Windows Environnement !

Please Support me by sharing if you like it and feel free to reach me out if getting any isssue !

Tags:

1 thought on “Setup your own git version control system on Windows 10”

Leave a Reply

Your email address will not be published. Required fields are marked *