September 22, 2021

COSFONE SYSTEM

Networking Equipment, Telecom Equipment, Ethernet Cables, Connectors, Tools

Raspberry Pi project : How to use Raspberry Pi to build git server?

Raspberry Pi project : How to use Raspberry Pi to build git server?

Raspberry Pi project : How to use Raspberry Pi to build git server?


Raspberry Pi project : How to use Raspberry Pi to build git server?

There are some private documents or codes that are inconvenient to put on github, which is inconvenient to manage. So you can build a private git server on the Raspberry Pi.

 

Installation dependencies

sudo apt-get install git-core

 

Create user

Here, create a git user for the Raspberry Pi, which is convenient for other users in the local area network to use and isolate the git server file from the pi user data. The command line is as follows:

adduser –system –shell /bin/bash –gecos’git version control by pi’ –group –home /home/git git

 


Change the git password:

passwd git

 

Now you can switch to the git user:

su git


Initialize the warehouse

The git user is responsible for the management of the git project. I store all the warehouses in /home/git. Here we initialize an empty warehouse (remember after switching to the git user):

cd /home/git
mkdir test.git
cd test.git
git –bare init

 

Use warehouse

After the above Raspberry Pi server configuration is completed, we can use the warehouse on the local client.

In the client, we can directly use the corresponding warehouse, such as the above test.git:

git clone git@your_raspi_ip:/home/git/test.git

 

Or add the previous project to the warehouse:

git remote add origin git@your_raspi_ip:/home/git/test.git

 

Among them, your_raspi_ip is your Raspberry Pi IP address.

 

Then there are some git operations:

git add.
git commit -m “test repo”
git push origin master


Enjoy your private git service~

 


Leave a Reply