标签:des blog http ar io os 使用 sp for
使用阿里云Ubuntu 12.0.4 64位操作系统做git服务器。
首先git服务器有两种访问方式可以选择:http方式和ssh的方式,http方式更容易使用。
1、http方式的git服务器搭建以及使用git命令行访问:
1) Install Ubuntu Server, this is the base of our git server obviously
2) Now we need to install a couple of packages, these being ‘git-core’ and ‘apache2′, we do this like so:-
apt-get update apt-get install apache2 git-core
3) Now we need to create a new folder for your new repository and set some inital permissons, we do this like so:-
cd /var/www mkdir test-repo.git cd test-repo.git git --bare init git update-server-info chown -R www-data.www-data .
4) We now need to enable WebDAV on Apache2 of which we will use to serve the repository:-
a2enmod dav_fs
5) We now need to configure the access restrictions to our repository by creating the following file:-
/etc/apache2/conf.d/git.conf
Then fill it in with the following content:-
<Location /test-repo.git> DAV on AuthType Basic AuthName "Git" AuthUserFile /etc/apache2/passwd.git Require valid-user </Location>
Then save and close the file, lets move on to the next bit..
6) Next we need to create a user account of which you will need to use to browse of commit to the repository..
htpasswd -c /etc/apache2/passwd.git <user>
You could then be prompted to enter the password for the user too and confirm it!
7) Ok that’s it for the server side configuration… we just need to restart Apache2 like so and then we should be ready to move on to the client side stuff!
/etc/init.d/apache2 restart
…you can now move on to the client side stuff!
Ok so now we need to create a local (on your desktop machine) repository and then we’ll initiate the new remote repository… So, if your using Linux/MacOSX bring up the terminal and type the following commands:-
mkdir ~/Desktop/test-project cd ~/Desktop/test-project git init git remote add origin http://<user>@<server name or IP address>/test-project.git touch README git add . git commit -a -m “Initial import” git push origin master
Done! – Your intiial file named ‘README’ which currently is just blank has now been committed and you’ve pushed your code to your new git server which has now completed the Git reposity creation process, now in future you can ‘clone’ your resposity like so:-
git clone <user>@<server name or IP address>/test-project.git
注意上面连接http://<user>@<server name or IP address>/test-project.git中的user就是你htpasswd -c /etc/apache2/passwd.git <user>输入的用户名。
参考资料:http://blog.bobbyallen.me/2012/07/23/installing-a-git-server-using-apache-webdav-on-ubuntu-server-12-04/
2、ssh方式访问的git服务器:
参考:http://blog.csdn.net/sbvfhp/article/details/8013945以及http://www.blogjava.net/jasmine214--love/archive/2014/01/15/408987.html
主要参考第一个博客,但第一个博客中的:git clone git://eagain.net/gitosis.git的地址是不能用的,使用第二个博客中的git clone https://github.com/res0nat0r/gitosis.git
3、客户端的配置:
我们客户端使用VS2013的IDE,所以我们选择git extensions+git source control provider,在【工具】->【扩展和更新】->“联机”选项卡,搜索对应名字即可。
安装git extensions时如果没MsysGit和KDiff,则勾选安装。
标签:des blog http ar io os 使用 sp for
原文地址:http://www.cnblogs.com/albert1017/p/4173490.html