1. Install httpd, git, and gitweb on the server.
| 1 |
#yum install httpd git git-daemon gitweb |
2. initialize the repository on the server
| 123 |
#mkdir -p /data3/gitserver#cd /data3/gitserver# Git init -- bare git_repo # initialize a bare Repository |
3. submit the initial file to the bare warehouse
| 1234567 |
#cd /tmp#git clone /data3/gitserver/git_repo#cd git_repo#touch MD#git add MD#git commit -m "init readme txt" MD#git push origin master |
4. Create a smart HTTP protocol so that you can access the GIT repository using the HTTP protocol.
| 12 |
#cd /etc/httpd/conf.d#vim git.conf |
Add the following configuration file
| 12345678910 |
ScriptAlias /gitserver/ /usr/libexec/git-core/git-http-backend/ <Directory "/usr/libexec/git-core/"> SetEnv GIT_PROJECT_ROOT /data3/gitserver SetEnv GIT_HTTP_EXPORT_ALL SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER Options +ExecCGI Order allow,deny Allow from all</Directory> |
5. Configure gitweb information to access the GIT repository through the web;
Enter the GIT repository path
| 1234 |
# Set the path to git projects. This is an absolute filesystem path which will# be prepended to the project path.#our $projectroot = "/var/lib/git";$projectroot = "/data3/gitserver"; |
6. Restart httpd
| 12 |
#chkconfig httpd on#service httpd start |
7. View git Repository
Http: // ip_address/git
8. Clone git Repository
| 1 |
git clone http://ip_address/gitserver/git_repo |
9. If push fails, perform the following operations on the server:
| 1234 |
#git push origin master# If git push fails#cd /data3/git_server/git_repo# git config daemon.receivepack true
|
If gitweb prompts that the project cannot be found, the permission for the/usr/local/Gerrit/git directory may be insufficient.
Configure Gerrit1. Edit the configuration file Vim/data/Gerrit/etc/Gerrit. config and add [gitweb] CGI =/var/www/git/gitweb. cgi2. Restart Gerrit.