Skip to content

Instantly share code, notes, and snippets.

@Misaka-0x447f
Last active March 10, 2018 06:46
Show Gist options
  • Save Misaka-0x447f/6537cb8ef9ff5d7cd10c60e5e3c80925 to your computer and use it in GitHub Desktop.
Save Misaka-0x447f/6537cb8ef9ff5d7cd10c60e5e3c80925 to your computer and use it in GitHub Desktop.
Git Repo On Server + Merge Permission Control

This documention are aim to introduce how to make some git repo like title described. This may useful for users who not want to make repo on some online service like github or gitlab due to very expensive costs.

#0 - Getting your server ready

First of all you absolutely need a server with a public address and a package manager. In this article I got a server with CentOS Linux release 7.3.1611 (Core) and I'm root.

Root isn't always harmful especially if not on a production server but you are recommended to come with a long enough password to keep root safe. (Don't worry to lost it at most time - you can always reset password on the server's dashboard.)

And, SSH client. Personally recommend MobaXterm. Putty is okay but please don't download it on some bad guy's website like baidu/360. Just go to the official site and download it, you will be safe.

#1 - yum install

Ref: https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7

↓ This is what you need to type and press enter.

yum install git
yum install openssh

You will be asked "Is this okay", just type Y.

For other pkg manager just install the package with the same name. This is very international.

You can check git version if you needs:

git --version

Ofcourse you can compile it yourself but if you can you will not need this article.

Now the git is ready. We are going to do some prepare for gitolite.

#2 - Install gitolite

Ref:

https://www.unixmen.com/install-gitolite-centos-7/

https://github.com/sitaramc/gitolite

https://www.google.com.hk/search?q=Can%27t%20locate%20Data/Dumper.pm

#2.1 - Preparation

We will need to create a user for gitolite.

adduser git
passwd git

For now we can simply set passwd to a random password - you can always reset it.

Then we need to create a SSH public key. *putty format is not supported here.

Type this and following instrtuction:

ssh-keygen

When you are ready with a RSA key, you will need copy it to this path:

/home/git

and update bash:

source .bash_profile

#2.2 - Install Gitolite

Switch to user "git":

su - git

Git clone the latest gitolite.

git clone git://github.com/sitaramc/gitolite

Install.

mkdir ~/bin
gitolite/install -to ~/bin

###Troubleshootings for install:

#0: yum install perl-Data-Dumper. This works for me.

#1: goto latest release page and wget, unzip, and https://stackoverflow.com/questions/18575287/installing-gitolite-without-cloning-gitolite-repo

#2: https://segmentfault.com/q/1010000000380149

#3: yum install perl-devel

Setup gitolite with the public key.

gitolite setup -pk id_rsa.pub

If the last command doesn't run perhaps "bin" is not in your "PATH". You can either add it, or just run:

$HOME/bin/gitolite setup -pk id_rsa.pub

#2.3 - Verify your install

Switch to the account where you created the SSH keys.

Try to git clone the gitolite-admin repository from your newly installed Gitolite server.

To do so, run:

git clone git@<ip-address>:gitolite-admin

#3 - Future reading

http://gitolite.com/gitolite/basic-admin/index.html

http://gitolite.com/gitolite/index.html

https://stackoverflow.com/questions/29839688/gitolite-restrict-access-to-branch

https://www.linux.com/learn/give-your-git-repository-open-source-web-interface

https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment