SSH+Git Server on Windows – 在Windows下搭建Git服务器 | 少将全栈
  • 欢迎访问少将全栈,学会感恩,乐于付出,珍惜缘份,成就彼此、推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 吐槽,投稿,删稿,交个朋友
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏少将全栈吧

SSH+Git Server on Windows – 在Windows下搭建Git服务器

点滴 admin 10年前 (2015-01-22) 2284次浏览 已收录 扫描二维码

软件需求:
1.windowXP, win7 都测试通过
2.Copssh_3.1.4_Installer.exe
3.Git-1.7.3.1-preview20101002.exe

搭建git服务器步骤:
1.安装copssh
1.1  我选择安装路径c:ICW,其他选项都选默认.
1.2 设置环境变量,系统的Path中添加C:ICWbin
1.3 右键 我的电脑,选择 管理,打开 系统工具->本地用户和组->用户,  在用户窗口点击右键,选择 新用户,用户   名输入git,密码输入git.
1.4.选择git用户,右键 选属性, 点击 隶属于->添加,使git用户被添加到administrator组,并拥有administrator权限.
1.5 选择 开始->所有程序->copssh->0.1 activate a user,在user name下拉列表中选择刚刚新建的git用户,点击next,输入 Type a passhrase,并记住输入的Type a passhrase,点击 activate.
2.安装git
2.1  我选择安装路径c:git,其他选项都选默认.
2.2 设置环境变量,系统的Path中添加C:gitbin
3.检验设置
3.1 打开一个cmd,输入 ssh git@127.0.0.1,按照提示输入密码,(我上面设置的是git),出现远程登录,git用户ssh登录成功
3.2 登录成功后,可以使用ls,cd,rm,chmod等命令,但是不能使用git命令,也就是不能使用ssh协议管理git仓库.
4.设置使用ssh协议 管理git 仓库
4.1开始-> CopSSH > Start a unix bash shell.
4.2 cd /Bin
4.3 创建 4个符号连接指向 git.exegit-receive-pack.exegit-upload-archive.exegit-upload-pack.exe

<span class="pln">$ ln </span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">s </span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">cygdrive</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">c</span><span class="pun"><span style="color:#666600;">/</span></span><span class="typ"><span style="color:#660066;">g</span></span><span class="typ"><span style="color:#660066;">it</span></span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">bin</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">git</span><span class="pun"><span style="color:#666600;">.</span></span><span class="pln">exe git</span><span class="pun"><span style="color:#666600;">.</span></span><span class="pln">exe 
$ ln </span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">s </span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">cygdrive</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">c/<span style="color:#660066;">g</span></span><span class="typ"><span style="color:#660066;">it</span></span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">libexec</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">core</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">receive</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">pack</span><span class="pun"><span style="color:#666600;">.</span></span><span class="pln">exe git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">receive</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">pack</span><span class="pun"><span style="color:#666600;">.</span></span><span class="pln">exe 
$ ln </span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">s </span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">cygdrive</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">c/<span style="color:#660066;">g</span></span><span class="typ"><span style="color:#660066;">it</span></span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">libexec</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">core</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">upload</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">archive</span><span class="pun"><span style="color:#666600;">.</span></span><span class="pln">exe git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">upload</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">archive</span><span class="pun"><span style="color:#666600;">.</span></span><span class="pln">exe 
$ ln </span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">s </span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">cygdrive</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">c/</span><span class="pun"><span style="color:#666600;"><span style="color:#660066;">g</span></span></span><span class="typ"><span style="color:#660066;">it</span></span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">libexec</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">core</span><span class="pun"><span style="color:#666600;">/</span></span><span class="pln">git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">upload</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">pack</span><span class="pun"><span style="color:#666600;">.</span></span><span class="pln">exe git</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">upload</span><span class="pun"><span style="color:#666600;">-</span></span><span class="pln">pack</span><span class="pun"><span style="color:#666600;">.</span></span><span class="pln">exe 

 4.4 退出git账号,打开一个cmd,输入</span>ssh git@127.0.0.1,重新登录,登录成功后,输入git 命令,会出现git命令的使用帮助.
     或者直接打开一个cmd,输入git,同样会出现git命令的使用帮助,表明可以正常使用git命令了.
 4.5 启动一个cmd,进入到C:ICWvar目录下,依次执行
     mkdir test
     cd test
     git init
     touch a b 
     git add .


     git config --global user.name "jackylee"  //用于添加提交用户信息
     git config --global user.email "orange.jackylee@gmail.com"//用于添加用户提交信息

     git commit -m  "first commit"


     使用git show 可以看到提交的信息和用户信息

4.5 启动一个cmd,我准备要把服务器管理的test仓库 拷贝到e:,   所以输入 cd e: ,执行拷贝
git clone git@127.0.0.1:../../var/test  test     (路径是相对路径,相对于git账号登录后的c:ICWhomegit目录)
4.6拷贝完成.cmd输出.
Cloning into test…
git@127.0.0.1’s password:
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.   
4.7 创建git账号信息,用于提交时区分哪个账号提交了什么内容.
登录git账号,输入pwd,输出为/home/git,
输入
touch .gitconfig
echo “[user]” > .gitconfig
echo “name=jackylee” >> .gitconfig
echo “email=orange.jackylee@gmail.com” >> .gitconfig
其他账号创建与创建git账号相同
5 让git 管理其他路径下文件.比如要让git管理e:project目录
启动cmd,进入e:project
依次输入
git init
git add .
git commit -m “first commit”
启动一个cmd,进入C:ICWvar
依次输入
ln -s e:project  project
现在已经可以使用git clone来管理e:project目录了
输入:git clone git@127.0.0.1:../../var/project  project_backup

以上一个完整的xp  git服务器已经设置完成.
问题备忘:
 – if cannot push to remote repo
 change the bare = true  in .gitconfig
 if is bare option, cannot checkout
  – ssh git@v:….test test
related location
3. c:git;c:icw has settings

喜欢 (0)
[🍬谢谢你请我吃糖果🍬🍬~]
分享 (0)
关于作者:
少将,关注Web全栈开发、项目管理,持续不断的学习、努力成为一个更棒的开发,做最好的自己,让世界因你不同。