Preface: why we need a private git server?

As a indie game dev, maybe we have many game code to manage, if you want use git for version control and don’t want to public your game code in github, also if you want to share game code between PC and Mac, I recommend you read my this article, the following step by step is show How to build your private git server in Raspberry Pi, it also fits for your Linux System Host 🙂

Part 1: How to build your private git server in raspberry pi?

step 1:
enter the commad interface and type the following command,

sudo apt-get install wget git-core  #install the git-core
sudo apt-get install ssh            #install the SSH
sudo /etc/init.d/ssh start          #start up the SSH service
sudo update-rc.d ssh defaults       #set up default start up

step 2: add a git user and group,

sudo adduser --system --shell /bin/bash --gecos 'git version control by pi' --group --home /home/git git
sudo passwd git  #set a password
su git           #switch to git user

until now, your have built your own git server in the raspberry pi,
you need add a git repository and clone it to your PC now.

Part 2: How to add your git repository and clone it to PC?

1

step 1: use the su git command to switch to git user mode, it needs the password;

1

step 2: use the cd command switch to git directory,

cd /home/git

add a git repository such as test.git and init it,

mkdir test.git
cd test.git
git --bare init

you have successfully added a git repository;

1

step 3: Create a folder in any directory on your work computer, such as D:\MyProjects, and use the git clone command,

#192.168.0.106 is my raspberry pi server IP in the local area network
git clone git@192.168.0.106:/home/git/test.git   

add your project to the repository folder, then you can do anything like the following git command,

git add .
git commit -m "first commit"
git push

1

type the following command, you can delete the git repository:

sudo chmod -R 777 test.git
sudo rm -rf test.git

(The End)

Last modified: March 17, 2019

Author

Comments

Author
iPixelGames 

if you have any questions, please leave a reply, thank you;)

Leave a Reply