Centos build git repository gitosis

  

Then yesterday's live, we wrote the markdown file to be transferred to the ./_posts/folder, and then generated by jekyll, so we need to use git to help us synchronize files. (Of course ftp/sftp/rsync can also, but with git I heard that it can be installed 13) First, you need to set up a git repository gitosis on vps. 1. Install python-setuptoolswget https://pypi.python.org/packages/source/s/setuptools/setuptools-1.1.7.tar.gztar zxvf setuptools-1.1.7.tar.gzcd setuptools-1.1.7python setup. Py buildpython setup.py install

2, install gityum -y install git

3, install gitosisgit clone https://github.com/tv42/gitosis.git #Get the latest gitosiscd gitosis # Go to the gitosis folder python setup.py install

4, generate rsa public key and private key ssh-keygen -t rsa #generate key, all the way back, no password cp ~/.ssh/Id_rsa.pub /tmp/id_rsa.pub #Copy the public key .pub file to the tmp folder

5, initialize gitosisuseradd git #add git user su - git #switch to git user for gitosis- Init < /tmp/id_rsa.pub #just put id_rsa.pub in the /tmp directory. The main reason is that rm /tmp/id_rsa.pub #OK, id_rsa.pub has permissions for everyone in this directory. It can be deleted.

6, get and configure gitosis administrator su - root #Switch back to root user git clone under root git@localhost:gitosis-admin.git #次Steps if error You can use the following #git clone git@localhost:/home/git/repositories/gitosis-admin.git

The configuration of gitosis is basically complete, gitosis-admin/gitosis.conf is the repository configuration file. You need to add a new project or modify the project corresponding to the user to modify it.

The following are some practical examples:

Add a lalala project in the git repository, the project member is test

First modify the gitosis-admin/gitosis.conf file in the file Join later: [group group name] writable = project name # is generally the name of the code library to be created members = member name # member name must be consistent with the .pub public key in the keydir folder; can have multiple members, with spaces Splitting

The group name is free, the project name is filled with lalala, the member is filled with test, and the save is exited.

Push the configuration file into the repository. git add .git commit -am "add project lalala"git push git@localhost:gitosis-admin.git master

Assume member test is in another To use the machine, first generate ssh-keygen -t rsa on that, put the generated id_rsa.pub into the gitosis-admin/keydir directory above, and rename it to test.pub (the file name is consistent with the member name. Pub cannot be omitted). Then git push again, then test has access to the project lalala.

Then execute on the local machine of test: mkdir lalalacd lalalagit inittouch test.txtgit add .git commit -am "add test.txt"git push git@your-gitosis-server:lalala.git master

test will build the lalala project locally.

As for multiple users accessing a project, just add the name in gitosis.conf and put the corresponding id_rsa.pub into the keydir.

If you want to execute system commands after git push is complete, you can use the hook function.

More usage please google--

Copyright © Windows knowledge All Rights Reserved