在 Windows 上使用 msysgit 设置 Git 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1482824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setup a Git server with msysgit on Windows
提问by
My friends and I are trying to setup Git for Windows using the tutorial Git Server: Gitosis and Cygwin on Windows, but we just keep running into problems.
我和我的朋友正在尝试使用教程Git 服务器:Windows 上的 Gitosis 和 Cygwin为 Windows 设置 Git ,但我们一直遇到问题。
What would a "Setup Git Server" guide for Windows using msysgitbe like?
使用msysgit 的Windows 的“设置 Git 服务器”指南会是什么样的?
There is a comment in the tutorial above suggesting it can't be done with msysgit because gitosis requires the use of an SSH Server and Bash? What is a step by step guide (as there is not one available)?
上面的教程中有一条评论表明它不能用 msysgit 完成,因为 gitosis 需要使用 SSH 服务器和 Bash?什么是分步指南(因为没有可用的指南)?
Install mysisgit
?
安装 mysisgit
?
回答by Tim
I found this post and I have just posted something on my blog that might help.
我找到了这篇文章,我刚刚在我的博客上发布了一些可能有帮助的内容。
See Setting up a Msysgit Server with copSSH on Windows. It's long, but I have successfully got this working on Windows 7 Ultimate x64.
请参阅在 Windows 上使用 copSSH 设置 Msysgit 服务器。它很长,但我已经成功地在 Windows 7 Ultimate x64 上运行。
回答by Daniel
Bonobo Git Server for Windows
适用于 Windows 的 Bonobo Git 服务器
From the Bonobo Git Server web page:
Bonobo Git Server for Windows is a web application you can install on your IIS and easily manage and connect to your git repositories.
Bonobo Git Server is a open-source project and you can find the source on github.
适用于 Windows 的 Bonobo Git Server 是一个 Web 应用程序,您可以将其安装在 IIS 上并轻松管理和连接到您的 git 存储库。
Bonobo Git Server 是一个开源项目,你可以在 github 上找到 源代码。
Features:
特征:
- Secure and anonymous access to your git repositories
- User friendly web interface for management
- User and team based repository access management
- Repository file browser
- Commit browser
- Localization
- 安全和匿名访问您的 git 存储库
- 用于管理的用户友好 Web 界面
- 基于用户和团队的存储库访问管理
- 存储库文件浏览器
- 提交浏览器
- 本土化
Brad Kingsleyhas a nice tutorialfor installing and configuring Bonobo Git Server.
Brad Kingsley有一个很好的教程来安装和配置 Bonobo Git Server。
GitStack
GitStack
Git Stackis another option. Here is a description from their web site:
Git Stack是另一种选择。这是他们网站上的描述:
GitStack is a software that lets you setup your own private Git server for Windows. This means that you create a leading edge versioning system without any prior Git knowledge. GitStack also makes it super easy to secure and keep your server up to date. GitStack is built on the top of the genuine Git for Windows and is compatible with any other Git clients. GitStack is completely free for small teams1.
GitStack 是一款软件,可让您为 Windows 设置自己的私有 Git 服务器。这意味着您无需任何 Git 知识即可创建领先的版本控制系统。GitStack 还让您的服务器安全和保持最新状态变得非常容易。GitStack 建立在 Windows 的正版 Git 之上,并与任何其他 Git 客户端兼容。GitStack 对小型团队完全免费1。
1the basic editionis free for up to 2 users
1的基本版本是免费的,最多2个用户
回答by Steve
With regards to the reference to the Tim Davis page - Setting up a Msysgit Server with copSSH on Windows- I used this to get a Git server running on Windows 7 Home Premium 64.
关于对 Tim Davis 页面的引用 -在 Windows 上使用 copSSH 设置 Msysgit 服务器- 我使用它来获取在 Windows 7 Home Premium 64 上运行的 Git 服务器。
Below is a postmortem/update of what I learned in addition to his instructions.
除了他的指示之外,以下是我对所学知识的事后分析/更新。
Like Tim Davis said, this was an arduous and frustrating process, at least for me - I'm not too good with integration of this sort, but I learned alot in the process. I hope my pain benefits someone else in the future, because this was an arduous process.
正如蒂姆戴维斯所说,这是一个艰巨而令人沮丧的过程,至少对我来说 - 我不太擅长这种整合,但我在这个过程中学到了很多东西。我希望我的痛苦将来可以让其他人受益,因为这是一个艰巨的过程。
There is a step to copy all the Git executables into your CopSsh bin directory. Instead of copying files and figuring out which files are needed, add the git bin path to your git path. I did so by modifying my .bashrc and CopSsh profile.
Here's what I added to .bashrc (in your CopSsh and Windows home directory):
gitpath='/cygdrive/c/Program Files (x86)/Git/bin'
gitcorepath='cygdrive/c/Program Files (x86)/Git/libexec/git-core'
PATH=${gitpath}:${gitcorepath}:${PATH}
Here's what I added to the bash profile (in CopSsh etc/profile):
gitpath='/c/Program Files (x86)/Git/bin'
gitcorepath='cygdrive/c/Program Files (x86)/Git/libexec/git-core'
export PATH="/bin:$syspath:$gitpath:$gitcorepath:$winpath"
There is some duplication here - it works for me, so someone chime in which is the correct place to modify the path.
The newer msysgit versions might not give you the screen to choose the ssh executable where you choose between the Git ssh and PuTTY ssh. You'll have to set GIT_SSH manually if you use PuTTY.
I didn't follow one part of the instructions and that was installing Tortoise - I used the command line instead as that's how I prefer to learn a vcs like I did with rcs and Subversion and found that to work for me. I had problems with the clone command using ssh. Here's how I did it:
Git clone using ssh - can't find repository
This is where I banged my head the most.
The CopSsh install directory was /Program Files (x86)/ICW. I got away with this, but if I were doing it again, I'd use a directory name with no spaces.
These other sources helped me figure things out:
Another way to setup a Git server on Windows:
http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP
The client side of things:
http://toolmantim.com/thoughts/setting_up_a_new_remote_git_repository
An explanation of Git as a server (not related to Windows, but a more in depth look than installation steps):
http://progit.org/book/ch4-0.html
Plus O'Reilly's Version Control with Git- the Remote Repositories chapter.
有一个步骤可以将所有 Git 可执行文件复制到您的 CopSsh bin 目录中。不要复制文件并找出需要哪些文件,而是将 git bin 路径添加到您的 git 路径中。我通过修改我的 .bashrc 和 CopSsh 配置文件来做到这一点。
这是我添加到 .bashrc 的内容(在您的 CopSsh 和 Windows 主目录中):
gitpath='/cygdrive/c/Program Files (x86)/Git/bin'
gitcorepath='cygdrive/c/Program Files (x86)/Git/libexec/git-core'
PATH=${gitpath}:${gitcorepath}:${PATH}
这是我添加到 bash 配置文件中的内容(在 CopSsh 等/配置文件中):
gitpath='/c/Program Files (x86)/Git/bin'
gitcorepath='cygdrive/c/Program Files (x86)/Git/libexec/git-core'
导出路径="/bin:$syspath:$gitpath:$gitcorepath:$winpath"
这里有一些重复 - 它对我有用,所以有人在哪个是修改路径的正确位置。
较新的 msysgit 版本可能不会为您提供选择 ssh 可执行文件的屏幕,您可以在其中选择 Git ssh 和 PuTTY ssh。如果您使用 PuTTY,则必须手动设置 GIT_SSH。
我没有按照说明的一部分操作,那就是安装 Tortoise - 我使用命令行代替,因为这是我更喜欢学习 vcs 的方式,就像我使用 rcs 和 Subversion 所做的那样,并发现它对我有用。我在使用 ssh 的克隆命令时遇到了问题。这是我如何做到的:
这是我最头疼的地方。
CopSsh 安装目录是 /Program Files (x86)/ICW。我逃脱了这个,但如果我再做一次,我会使用一个没有空格的目录名。
这些其他来源帮助我弄清楚了:
在 Windows 上设置 Git 服务器的另一种方法:
http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP
客户端的事情:
http://toolmantim.com/thoughts/setting_up_a_new_remote_git_repository
Git作为服务器的解释(与Windows无关,但比安装步骤更深入):
http://progit.org/book/ch4-0.html
加上 O'Reilly 的Git 版本控制- 远程存储库章节。
In retrospect, if I had known how time consuming this would be, I might have started out with Mercurial as I read the install on Windows is easier, but I'll have an opinion on that after I work with Git awhile and then try Mercurial.
回想起来,如果我知道这会有多耗时,我可能会从 Mercurial 开始,因为我阅读了在 Windows 上的安装更容易,但是在我使用 Git 一段时间后我会对此发表意见,然后尝试 Mercurial .
回答by Pritesh Patel
I am not sure why anyone hasn't suggested http://gitblit.com. Pure java based solution, allow HTTP protocol and really easy to setup.
我不确定为什么没有人建议http://gitblit.com。纯基于 Java 的解决方案,允许 HTTP 协议并且非常容易设置。
回答by timc
After following Tim Davis' guide and Steve's follow-up, here is what I did:
在遵循 Tim Davis 的指南和 Steve 的跟进之后,这是我所做的:
Server PC
服务器电脑
- Install CopSSH, msysgit.
- When creating the CopSSH user, uncheck Password Authenticationand check Public Key Authenticationso your public/private keys will work.
- Create public/private keys using PuTTygen. put both keys in the user's CopSSH/home/user/.ssh directory.
Add the following to the user's CopSSH/home/user/.bashrc file:
GITPATH='/cygdrive/c/Program Files (x86)/Git/bin' GITCOREPATH='/cygdrive/c/Program Files (x86)/Git/libexec/git-core' PATH=${GITPATH}:${GITCOREPATH}:${PATH}
Open Git Bash and create a repository anywhere on your PC:
$ git --bare init repo.git Initialized empty Git repository in C:/repopath/repo.git/
- 安装 CopSSH、msysgit。
- 创建 CopSSH 用户时,取消选中Password Authentication并选中Public Key Authentication以便您的公钥/私钥可以工作。
- 使用 PuTTygen 创建公钥/私钥。将两个密钥都放在用户的 CopSSH/home/user/.ssh 目录中。
将以下内容添加到用户的 CopSSH/home/user/.bashrc 文件中:
GITPATH='/cygdrive/c/Program Files (x86)/Git/bin' GITCOREPATH='/cygdrive/c/Program Files (x86)/Git/libexec/git-core' PATH=${GITPATH}:${GITCOREPATH}:${PATH}
打开 Git Bash 并在您的 PC 上的任何位置创建一个存储库:
$ git --bare init repo.git Initialized empty Git repository in C:/repopath/repo.git/
Client PC
客户端电脑
- Install msysgit.
- Use the private key you created on the server to clone your repo from ssh://user@server:port/repopath/repo.git(for some reason, the root is the C: drive)
- 安装 msysgit。
- 使用您在服务器上创建的私钥从ssh://user@server:port/repopath/repo.git克隆您的 repo (出于某种原因,根是 C: 驱动器)
This allowed me to successfully clone and commit, but I could not push to the bare repo on the server. I kept getting:
这使我能够成功克隆和提交,但我无法推送到服务器上的裸仓库。我不断得到:
git: '/repopath/repo.git' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly
This led me to Rui's trace and solutionwhich was to create or add the following lines to .gitconfig in your Client PC's %USERPROFILE%path (C:\Users\UserName).
这让我找到了Rui 的跟踪和解决方案,即在客户端 PC 的 %USERPROFILE%路径 (C:\Users\UserName) 中创建或添加以下行到 .gitconfig 。
[remote "origin"]
receivepack = git receive-pack
I am not sure why this is needed...if anybody could provide insight, this would be helpful.
我不确定为什么需要这样做……如果有人可以提供见解,这会有所帮助。
my git version is 1.7.3.1.msysgit.0
我的 git 版本是 1.7.3.1.msysgit.0
回答by poiuytrez
回答by Ruslan Platonov
There is a nice open source Git stack called Git Blit. It is available for different platform and in different packages. You can also easily deploy it to your existing Tomcat or any other servlet container. Take a look at Setup git server on windows in few clickstutorial for more details, it will take you around 10 minutes to get basic setup.
有一个很好的开源 Git 堆栈,称为 Git Blit。它适用于不同的平台和不同的包。您还可以轻松地将其部署到现有的 Tomcat 或任何其他 servlet 容器。看看在windows 上点击几下设置 git 服务器的教程了解更多详细信息,大约需要 10 分钟才能完成基本设置。
回答by Jon Watte
You don't need SSH for sharing git. If you're on a LAN or VPN, you can export a git project as a shared folder, and mount it on a remote machine. Then configure the remote repo using "file://" URLs instead of "git@" URLs. Takes all of 30 seconds. Done!
您不需要 SSH 来共享 git。如果您在 LAN 或 VPN 上,您可以将 git 项目导出为共享文件夹,并将其挂载到远程机器上。然后使用“file://” URL 而不是“git@” URL 配置远程仓库。需要全部 30 秒。完毕!
回答by Bob Murphy
There may simply not be such a guide. If so, you may not have much luck convincing anybody to write one, because it would be a lot of work.
可能根本就没有这样的指南。如果是这样,您可能没有多少运气说服任何人写一个,因为这将是很多工作。
I would recommend either of two things. The easier one is to follow the guide you have slavishly, which means forgetting about msysgit.
我会推荐两件事中的任何一件。更简单的方法是严格按照您的指南进行操作,这意味着忘记 msysgit。
The harder one is to put up a Linux server - perhaps as a guest under Windows using VirtualBox (free) or VMWare or Parallels (pay), and then follow one of the many sets of instructions Google will lead you to. But you will probably find those instructions are insufficient - they usually assume you've already set up an ssh server, for example, so you have to get that info elsewhere. I've done that twice, and can say that unless you're already something of a Linux guru, it will be a struggle.
更难的一个是搭建一个 Linux 服务器——也许作为 Windows 下的访客使用 VirtualBox(免费)或 VMWare 或 Parallels(付费),然后按照谷歌将引导你的许多指令集之一。但是您可能会发现这些说明是不够的——例如,他们通常假设您已经设置了 ssh 服务器,因此您必须在其他地方获取该信息。我已经这样做了两次,可以说除非您已经是 Linux 大师,否则这将是一场斗争。
回答by Jacob Stanley
I did what Bob Murphysuggested was the "hard" option.
我做了鲍勃墨菲建议的“硬”选项。
I installed Ubuntu under VMWare Server (free) at work and then followed this guideon setting up Gitosis. I found it much easier than trying to get it going under Windows. Once it's set up you really don't have to touch it because Gitosis administration can be done from Windows by pushing updated versions of the gitosis.conf file. Any work I do need to do on the server directly is done via PuTTY so I don't have to use the horrible VMWare Server interface.
我在工作时在 VMWare Server(免费)下安装了 Ubuntu,然后按照本指南设置 Gitosis。我发现它比尝试在 Windows 下运行要容易得多。一旦设置好,你就真的不需要去碰它了,因为 Gitosis 管理可以通过推送 gitosis.conf 文件的更新版本从 Windows 完成。我需要直接在服务器上做的任何工作都是通过 PuTTY 完成的,所以我不必使用可怕的 VMWare 服务器界面。
I've recently been messing around with VirtualBox at home and I've found it much nicer/easier to work with than VMWare Server, so it may be worth looking at that.
我最近一直在家里搞弄 VirtualBox,我发现它比 VMWare Server 更好/更容易使用,所以它可能值得一看。