在Windows 7中配置git私有源

引言

随着github的兴起,相信很多人熟悉了git。但是对于非付费用户来说,他/她只能创建共享 的源。在网上看了一下,找到了一个在windows上创建私有源的方法。

用到的工具有两个:

1. Git

这个首推msysgit.

2. SSH

我用的是CopSSH,它可以在Windows上启动SSH服务,而不仅是客户端。

安装并配置SSH

 

下载并安装CopSSH

配置SSH

  1. open the sshdconfig file located in "c:\program files\copssh\etc"
  2. uncomment and configure the following: Port 22 Protocol 2,1 AddressFamily any ListenAddress 10.10.11.60 PidFile /var/run/sshd.pid
  3. Restart the OpenSSH service
  4. Configure the Windows Firewall to allow internal connections on port 22.

Right click on inbound rules, select new rule, Port, TCP, 22, Allow the connection, Domain Private and Public. Give it a proper name and description.

Now everything is setup to work, but you have no users configured. Users should be created locally on the server, and then activated using Start > Programs > COPSSH > Activate a user. This writes a line to the etc/passwd file. You can edit this using runas and gvim. If you want to give the user access to files that exist outside of the copssh folder, use /cygdrive/Drive letter/path . As an example the D:\webs folder would be written as /cygdrive/d/webs .

Reference: http://tech.mikeal.com/blog1.php/ssh-sftp-for-windows-2008-server-using-c

创建无密码的SSH

命令如下:

ls ~/.ssh/id_rsa.pub
scp ~/.ssh/id_rsa.pub git@wangjiay-pc:
ssh git@wangjiay-pc

# Below commands run after the SSH logged in

mkdir -p .ssh
cat id_rsa.pub >> .ssh/authorized_keys


chmod 700 .ssh
chmod 400 .ssh/authorized_keys

Reference: http://blog.goosoftware.co.uk/2012/02/07/quick-git-server/

安装并配置Git

下载msysgit.

配置Git

在Git的安装目录里找到cmd目录。在里面创建如下几个文件: git, git-upload-pack, git-upload-archive, git-receive-pack。这里都没有扩展名的,主要是给登录后,由bash执行的。每个文件都只有一行,分别是: git里写 git.cmd $* git-upload-pack里写 git upload-pack $* git-upload-archive里写 git upload-archive $* git-receive-pack里写 git receive-pack $*

然后,就要给登录后的用户添加path了,保证上面添加的命令可以找到,并执行。在.bashrc的 最后添加两行:

gitpath='/cygdrive/d/apps/VCM/GIT/bin:/cygdrive/d/apps/VCM/GIT/cmd'
export PATH="$PATH:$gitpath"

reference: http://blog.csdn.net/mr_von/article/details/5192502

初始化git源

ssh git@wangjiay-pc

mkdir TestGit

cd TestGit
git init --bare

Post by: Jalen Wang (转载请注明出处)

posted on 2013-01-30 22:03  Jalen Wang  阅读(1800)  评论(1编辑  收藏  举报

导航