天天看點

Windows上搭建Git伺服器詳細教程(TortoiseGit + msysgit + CopSSH + WindowsXP ) Introduction Software Requirements On The Server On The Client

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

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 are the following:

msysgit 1.7.0.2 (client and server)

copssh 3.0.3 (server

only)

tortoisegit 1.4.4.0 (client only)

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.

install msysgit 1.7.0.2

choose plink, not openssh

choose git only on windows path (middle option)

install copssh

3.0.3 on the server machine

use default options during installation

by default, copssh installs to c:\program files\icw\

modify copssh configuration:

in c:\program files\icw\etc\sshd_config, make sure

the following is uncommented and set to "no":

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.

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.

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.

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.

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.

the ssh server won't be able to find the required git exes yet.

start > copssh > start a unix bash shell. on at least windows 7, this action must be performed while logged in under an administrator account.

cd /bin

create a symbolic link to git.exe, git-receive-pack.exe, git-upload-archive.exe, git-upload-pack.exe:

you must have been given:

a private key file, e.g. <user>.key

a pass phrase for the same private key

a user name to use, e.g. <user>

the name of a server, e.g. <server>

(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.)

choose plink

choose git only on windows path

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.

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.

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.

cloning the repository on the d: drive of the server:

url = <user>@<server>:d:/deedriverepos/repo2

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.