Introduction: Running Git Server on BrainyPi

Git is a version control system that is open source and is trusted by software development companies all over the world. It was originally developed by the creator of Linux Mr. Linus Torvalds in 2005. It can handle small projects to very large projects very easily.

Most importantly, you can run a git server in your office or your home very easily.

I am going to demonstrate this project on BrainyPi.

Supplies

You don't need a lot of things to get up and running

  1. BrainyPi or RaspberryPi
  2. Ethernet connection
  3. Keyboard
  4. Mouse
  5. Monitor

Step 1: Installation

1.1 Start by updating the operating system.

sudo apt update && sudo apt upgrade -y

The above commands updates the repositories and then updates the operating system.

1.2 Now, we will install git and its dependencies.

sudo apt-get install wget git-core


Step 2: Creating the Folders

2.1 We need a place for our code to call home. We can do that by creating a folder in our home directory.

mkdir ~/repositories/repo1.git/

Change the name of the folder to your preferences.

Step 3: Initialization

In this step we will initialize a git repository in our folder

3.1 This step needs to repeated for every repository.

git init --bare

3.2 Next step will be performed on your development machine.

Step 4: Navigating to the Code Files

On your development machine, open a terminal window and change to the directory where the code is stored.

cd D:\code\repo1\

4.1 In the next step we will connect git on our local machine to the git server installed on the BrainyPi

Step 5: Connecting Server and Client

Now, we will connect our client machine to the server.

git remote add pi@IP_ADDRESS_OF_PI:/home/pi/repositories/repo1.git/

Note: Remember to add the ip address.


Step 6: Pushing Code to the Pi

Now, all we need to do is run the git commands. To sync our code to the server

git add .
git commit -m "initial commit"
git push pi master

NOTE: For future management, just follow step 6.

NOTE: To add more repositories repeat steps3-5.

NOTE: To add more clients repeat step 5.