Reference:
http://blog.bobbyallen.me/2012/07/23/installing-a-git-server-using-apache-webdav-on-ubuntu-server-12-04/
https://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.html
How to set up a Git Server Over HTTP(s) in Ubuntu Servers
On the Server
1)
root@server# apt-get update
root@server# apt-get install apache2 git-core
2)
root@server# cd /var/www
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-data.www-data .
3)
root@server# root@server# a2enmod dav_fs
4)
root@server# cat > /etc/apache2/conf-available/git.conf
<Location /test-repo.git>
DAV on
AuthType Basic
AuthName "Git"
AuthUserFile /etc/apache2/passwd.git
Require valid-user
</Location>
5)
root@server# htpasswd -c /etc/apache2/passwd.git <user-id>
6)
root@server# /etc/init.d/apache2 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.
http://blog.bobbyallen.me/2012/07/23/installing-a-git-server-using-apache-webdav-on-ubuntu-server-12-04/
https://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.html
How to set up a Git Server Over HTTP(s) in Ubuntu Servers
On the Server
1)
root@server# apt-get update
root@server# apt-get install apache2 git-core
2)
root@server# cd /var/www
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-data.www-data .
3)
root@server# root@server# a2enmod dav_fs
4)
root@server# cat > /etc/apache2/conf-available/git.conf
<Location /test-repo.git>
DAV on
AuthType Basic
AuthName "Git"
AuthUserFile /etc/apache2/passwd.git
Require valid-user
</Location>
5)
root@server# htpasswd -c /etc/apache2/passwd.git <user-id>
6)
root@server# /etc/init.d/apache2 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.
댓글
댓글 쓰기