开发者社区> 雪梦科技> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

Windows上搭建Git服务器详细教程(TortoiseGit + msysgit + CopSSH + WindowsXP )

简介:
+关注继续查看

原文:http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP

Introduction

This guide will show you how to set up a centralized Git repository, which offers an option similar to a conventional subversion work-flow, with a centralized server.

This is not a difficult process; it is only a long sequence of simple steps.

Software Requirements

Software requirements are the following:

The 32bit versions of the software packages are linked. If installing for x64 on the server, substitute installation packages (and paths) appropriately. The x64 versions have not been tested on the server, and only the versions mentioned here have been tested; ymmv.

On The Server

  1. Install msysgit 1.7.0.2
    • Choose plink, not OpenSSH
    • Choose Git only on windows path (middle option)
  2. Install CopSSH 3.0.3 on the server machine
    • Use default options during installation
    • By default, CopSSH installs to C:\Program Files\ICW\
  3. Modify CopSSH configuration:
    • In C:\Program Files\ICW\etc\sshd_config, make sure the following is uncommented and set to "no":
      PasswordAuthentication no
  4. On server, in Windows:
    • Control Panel > User Accounts > Create new account
    • Create an account for each user to whom you wish to allow SSH access.
    • It is fine for these accounts to be "Limited", or non-Administrators.
  5. Activate these new user accounts in CopSSH:
    • Start > Programs > Copssh > "Activate a user"
    • Choose user account, leave other options as default (/bin/bash, etc.)
    • Type a passphrase. You must remember this passphrase: it is associated with the private key of the user being activated.
    • Finish.
  6. In C:\Program Files\ICW\home, there is a subfolder for each user account:
    • Inside each subfolder, send the <user>.key and <user>.key.pub files to the user, along with the pass phrase selected in (5) FOR THAT USER. They will need this information.
  7. Make a git repository:
    • Lets assume we want to serve 2 repos: one on C: drive and one on D: drive
    • On C: C:\SeeDriveRepos\Repo1\.git
    • On D: D:\DeeDriveRepos\Repo2\.git
    • For each parent folder, e.g. C:\SeeDriveRepos:
      • Right Click > Sharing and Security > Security > Users: "Modify" = Checked (note that "Write" becomes checked as well, which is fine)
      • This is needed for when a remote client wants to Push.
    • NOTE: It will be more likely that the central server will host a bare git repository. In this instance, the folder name will be something like \SeeDriveRepos\Repo.git. This does not change the subsequent discussion, except that the URL when specified from the client side must obviously match the folder name above, in terms of Repo.git.
    • Potential Gotcha: If you access and commit into this repository locally, in other words, while logged into the server directly, and using file-based access from a clone of this repository on the same server, then the HEADS file representing that branch will take on the security privileges of that user. In other words, doing this while logged in as Administrator will prevent all other non-admin users from modifying that HEADS file: they will be unable to make commits to that branch. There are various workarounds for this, including changing the write permissions on the folder tree of that repository to be valid for all ssh-enabled users, or making all ssh-user accounts (the Windows accounts) administrators, and so on.
  8. On server, ensure that the Firewall has port 22 open. This will allow incoming SSH traffic. Any other port-blocking software or hardware should have the same port open.
  9. The ssh server won't be able to find the required Git EXEs yet.
    1. Start > CopSSH > Start a unix bash shell. On at least Windows 7, this action must be performed while logged in under an Administrator account.
    2. cd /Bin
    3. Create a symbolic link to git.exe, git-receive-pack.exe, git-upload-archive.exe, git-upload-pack.exe:
      $ ln -s /cygdrive/c/Program\ Files\ \(x86\)/Git/bin/git.exe git.exe
      $ ln -s /cygdrive/c/Program\ Files\ \(x86\)/Git/libexec/git-core/git-receive-pack.exe git-receive-pack.exe
      $ ln -s /cygdrive/c/Program\ Files\ \(x86\)/Git/libexec/git-core/git-upload-archive.exe git-upload-archive.exe
      $ ln -s /cygdrive/c/Program\ Files\ \(x86\)/Git/libexec/git-core/git-upload-pack.exe git-upload-pack.exe 

On The Client

Requirements for client configuration

You must have been given:

  1. private key file, e.g. <user>.key
  2. pass phrase for the same private key
  3. a user name to use, e.g. <user>
  4. The name of a server, e.g. <server>

Configuration procedure

(NOTE: The path for program files below is for Windows XP x64, i.e. C:\Program Files (x86)\; For 32bit windows, just useC:\Program Files.)

  1. Install msysgit 1.7.0.2
    • Choose plink
    • Choose git only on windows path
  2. Install TortoiseGit 1.4.4.0
    • After installation, under Settings > Network > SSH:
    SSH Client = C:\Program Files (x86)\TortoiseGit\bin\TortoisePlink.exe
    • Potential gotcha: if you only work with other windows developers, you should consider disabling the auto-line-endings adjustment, and select the option to leave line endings unchanged. Spurious diffs related to line-endings transformations have been observed.
  3. Run C:\Program Files (x86)\TortoiseGit\bin\puttygen.exe:
    • The keys generated in CopSSH are OpenSSH keys, but we want to use putty keys with TortoiseGit; here, we convert the private key to a putty type.
    • Click button "Load" > Select file <user>.key
    • Save the converted private key somewhere, e.g. <user>.ppk
    • Close puttygen
    • Run C:\Program Files (x86)\TortoiseGit\bin\Pageant.exe
    • Add the newly created <user>.ppk
    • Enter the pass phrase for the private key when asked
    • NOTE: On every reboot, Pageant.exe must be started, and the key loaded, and the pass phrase entered.
  4. Clone the repositories from the server. Let's start with the C drive repo:
    • find a suitable location, and Right Click > Git Clone:
      • URL = <user>@<server>:c:/SeeDriveRepos/Repo1
      • If Pageant.exe is not running, and/or not correctly set up with the right key and passphrase, then set "Load Putty Key" (yes) = (path to <user>.ppk). Without Pageant.exe, you will be asked for your passphrase on every action.
    • click OK
    • A dialog will come up, asking whether ssh host information should be saved (yes/no): choose yes.
    • The repository should be successfully cloned. If this is not the case, make sure that Pageant.exe is running, and has the correct .ppk key loaded.
  5. Cloning the repository on the D: drive of the server:
    • URL = <user>@<server>:d:/DeeDriveRepos/Repo2
  6. For repositories on the C: drive of the server, the following URL will also work:
    • URL = ssh://<user>@<server>/SeeDriveRepos/Repo1
    • This format cannot be used for repositories on other drives of the server.

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Git服务器的搭建
Git服务器的搭建
72 0
GIT服务器搭建(转载)
一、GIT服务器的搭建 1. 安装Git yum -y install git 2. 创建git用户 adduser git 3. 创建证书登陆 收集所有客户端需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
675 0
Git命令使用总结
1.在GitHub上创建了一个新项目,如何将本地的一个工程上传上去 1) copy github项目地址 2) 在android studio中打开terminal命令行,执行命令将本项目所有代码添加 git add * 3)执行命令提交 git co...
1082 0
git初学常用命令解析
<div class="markdown_views"> <h1 id="git初接触核心指令">git初接触核心指令</h1> <h2 id="1-配置git的基本信息">1. 配置git的基本信息。</h2> <p>在每次提交时都会引用这两条基本信息,标识更新提交者,会随更新一起保存在log中 <br><code>git config –-global user.n
1531 0
Git常用命令
<span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:28px">1. Git概念 </span><br style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:28px; padding:
1086 0
git命令大全
<p></p> <h3 style="margin-bottom:15px; line-height:1.7; font-size:1.5em; margin-right:0px; margin-left:0px; padding:0px; position:relative; color:rgb(51,51,51); font-family:Helvetica,arial,freesa
1320 0
+关注
雪梦科技
专注Android应用研发,性能优化,移动安全等领域。
457
文章
6
问答
文章排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载