1. Installation and configuration of Git
(1) Install git using yum source
- Yum Install git
(2) Create a git user and set a password
- #useradd--home/home/git git
- #passwd git
- Note here to set a password, it is recommended not to set a password, a lot of information on the Internet do not set a password
(3) Create a git repository to verify that Git is available
- Before using Git, set two global variables for git in the following way:
-
- # git config--global user.name "Dylan"
- # git config--global user.email "[Email protected]"
- Set permissions for the GIT repository directory
-
- # Su-git//switch to git user
- $ chmod-r 755/home/git//Modify permissions for a directory
- Create and initialize a repository
-
- $ MKDIR/HOME/GIT/REPO//Assuming the repository to be created is placed in the/home/git/repo directory
- $ cd/home/git/repo
- $ mkdir Test_repo
- $ CD Test_repo
- $ git init--bare
- Test whether the newly created repository is available
-
- Su-test (test for another user or exit, using the root user)
- $ cd/home/test
- $ mkdir Repos
- $ CD Repos
- $ git Clone/home/git/repo/test_repo
If "Initialized empty Git repository in/home/git/repo/test_repo/.git/" is displayed, the successful clone has a local repository. It can then be developed under this repository, for example, by adding a Readme.txt file.
-
- $ CD Test_repo
- $ vim Readme.txt (Create a file)
- $ git Add. (Note that there is a [.] later)
- $ git commit-a
- $ GIT push origin master
Note: If there is an error at this point, the biggest reason is that Test_repo refs and the objects directory have insufficient permissions to do the following (the two directories under the GIT server side of repository).
- $ chmod-r 777 refs/
- $ chmod-r 777 objects/
2. Installation of Gitosis(1) Installation of Python-setuptools (because Gitosis's installation script is written in Python)
- #yum Install Python-setuptools
(2) Installation of gitosis
- #git clone git://github.com/res0nat0r/gitosis.git//Download gitosis to the directory you want to store
- #cd gitosis
- #python setup.py Install//If there is no error, the installation is successful
(3) Create the public key of the user who is using this git server
Because gitosis access is accessed via SSH, we also need to create an SSH access key. Find another machine (if conditions allow) to create a public key as a client machine for the GIT server and then upload it to the GIT servers. (If you want to make it easy, you can create a public key on a git server, either with a git user or another user.) For convenience, git servers are used and GIT users are employed.
- # Su-git
- $ ssh-keygen-t RSA
The public key is generated, the default is placed under/home/git/.ssh/id_rsa.pub, if the public key is generated when the password is set, pay attention to remember the password, in order to be simple, I do not set the password here. (4) Configure gitosis gitosis to git management by gitosis-admin.git this project to complete, GITOSIS-ADMIN.GIT project itself is placed under git management, so you need to first on the client side clone Gitosis-admin.git, the changes can be submitted to Git server to take effect when modified according to requirements. The implication here is: where do you want to configure the gitosis, where you need to clone to Gitosis-admin.git.
- Assuming that gitosis is on a different machine, use a git user to Gitosis-admin.git clone to local.
-
- git clone [email protected]:/home/git/repositories/gitosis-admin.git
- Modify the gitosis configuration file gitosis.conf
-
- $ vim gitosis.conf
- You'll see something like this
- [Gitosis]
- [Group Gitosis-admin]
- writable = Gitosis-admin
- Members = [email protected]
The gitosis.conf file is used to set the user, The control file for the repository and permissions (for the detailed meaning of the gitosis.conf file, and the role of the public key under the Keydir directory, will be written in another document, no longer detailed here), just know that the Gitosis repository is writable and the supported users have git
(5) New Add repository Modify gitosis-admin configuration file gitosis.conf, add a new repository, for example:
- [Gitosis]
- [Group Gitosis-admin]
- writable = Gitosis-admin
- Members = [email protected]
- [Group Test_repo]//new warehouse name added
- writable = TEST_REPO//read/write permission for this warehouse, writable here
- Members = [email protected] [email protected]//user name with access to this warehouse @ hostname
Suppose that when User1 to access this Test_repo repository, you need to enter the following command:
- git clone [email protected]_server_ip:/home/git/repo/test_repo.git
You will be asked to enter a password for User1, which is the password you entered when you created the User1 public key. So how gitosis to determine the identity of User1? This requires that the public key generated by the User1 must be passed on to the administrator in advance, that is, a manager who has permission to operate on Gitosis-admin, who then copies the public key to the Keydir directory, and then executes the git add,git push.
3. Gitweb Installation
Note: The ISO source for Redhat is no gitweb installation package, but there is a CentOS source, in the previous article on how to get Redhat to use the source of CentOS, then just use the following command to install.
- # yum Install Gitweb
4. Gitweb Configuration
Gitweb is installed by default under/var/www/git, its configuration file under/etc/gitweb.conf, and httpd configuration file/etc/httpd/conf.d/git.conf. (1) Modify/etc/gitweb.conf
- $projectroot = "/var/www/git"//change Projectroot to/var/www/git
(2) Modify/etc/httpd/conf.d/git.conf
- Alias/git/var/www/git
- <Directory/var/www/git>
- Allow from all
- AllowOverride All
- Order Allow,deny
- Options +execcgi
- AddHandler Cgi-script. CGI
- DirectoryIndex gitweb.cgi
- SETENV gitweb_config/etc/gitweb.conf
- Dav on
- Rewriteengine OFF
- </Directory>
(3) Restart httpd
- /ETC/INIT.D/HTTPD restart
(4) Connect the Gitosis warehouse to the/var/www/git to complete the web display
- Ln-s/home/git/repositories/test_repo.git/var/www/git/
(5) Browsing through the browser http://xxxx/git/Note: If git clone http://xxx/git/test_repo.git update-server-info error occurs, the Test_ The git update-server-info command can be executed under the Repos.git directory (gitosis the appropriate repository for the server).
5. Create a new git repositoryUnder Git server's/home/git/repository directory, execute the following command:
- mkdir Test.git
- CD Test.git
- Git init--bare
- You can add the source file here, or you can add it after the client-side clone