How to set up a Git Server Over HTTP(s) in Redhad Distros.
On the Server
1)
root@server# yum install apache2 git-core
2)
root@server# cd /usr/local/apache/htdocs
root@server# mkdir test-repo.git
root@server# cd test-repo.git
root@server# git --bare init
root@server# git update-server-info
root@server# chown -R www.www . #don't miss this trailing dot at the end.
3)
root@server# root@server# vi /etc/httpd/conf/httpd.conf
....
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule authn_file_module modules/mod_authn_file.so
....
4)
root@server# root@server# vi /etc/httpd/httpd.conf
....
###############################
# Virtual Hosts Configuration #
###############################
<VirtualHost *:80>
DocumentRoot /usr/local/apache/htdocs
ServerName example.xxxxx.com
ServerAlias www.example.xxxxx.com
DAVLockDB "/etc/httpd/conf/DAV.lock"
<Location /repository.git>
Dav On
AuthType Basic
AuthName DAV
AuthUserFile /etc/httpd/conf/passwd.git
Require valid-user
<LimitExcept GET OPTIONS>
require user admin
</LimitExcept>
</Location>
</VirtualHost>
....
5)
root@server# htpasswd -c /etc/httpd/conf/passwd.git <user-id>
6)
root@server# /etc/init.d/httpd restart
On the client side
1) Push to Remote Server
user1@mycomp1$ mkdir -p ~/Work/test-project
user1@mycomp1$ cd ~/Work/test-project
user1@mycomp1$ git init
user1@mycomp1$ git remote add origin http://<user>@<servername or IPaddress>/test-project.git
user1@mycomp1$ touch README
user1@mycomp1$ git add README
user1@mycomp1$ git commit -a -m “Initial import”
user1@mycomp1$ git push origin master
2) clone from Remote Server
NOTE: it's a different computer
user2@mycomp2$ git clone http://<servername or IPaddress>/test-project.git /tmp/cloned-project
3) Add new file and then push to Remote Server
user2@mycomp2$ cd /tmp/cloned-project
user2@mycomp2$ touch NEWFILE
user2@mycomp2$ git add NEWFILE
user2@mycomp2$ git commit -a -m “add NEWFILE”
user2@mycomp2$ git remote rm origin # it removes a remote server aliased as ‘origin’ if there is any.
user2@mycomp2$ git remote add origin http://<user>@<servername or IPaddress>/test-project.git
# you can name whatevery alias your like instead of ‘origin’.
user2@mycomp2$ git push origin master
4) Fetch from and merge with “test-project.git” repository
user1@mycomp1$ cd ~/Work/test-project
user1@mycomp1$ git pull origin master
# this will fetch NEWFILE from remote repository and merge it with your working directory.
댓글
댓글 쓰기