在 Windows 中托管 Git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/233421/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:36:31  来源:igfitidea点击:

Hosting Git Repository in Windows

windowsgit

提问by Jeff Fritz

Is there currently a way to host a shared Git repository in Windows? I understand that you can configure the Git service in Linux with:

目前有没有办法在 Windows 中托管共享 Git 存储库?我知道你可以在 Linux 中配置 Git 服务:

git daemon

Is there a native Windows option, short of sharing folders, to host a Git service?

是否有本地 Windows 选项(缺少共享文件夹)来托管 Git 服务?

EDIT: I am currently using the cygwin install of git to store and work with git repositories in Windows, but I would like to take the next step of hosting a repository with a service that can provide access to others.

编辑:我目前正在使用 git 的 cygwin 安装来存储和使用 Windows 中的 git 存储库,但我想采取下一步托管存储库的服务,该服务可以为其他人提供访问权限。

采纳答案by Derek Greer

Here are some steps you can follow to get the git daemon running under Windows:

以下是您可以遵循的一些步骤,以使 git 守护程序在 Windows 下运行:

(Prerequisites: A default Cygwin installation and a git client that supports git daemon)

(先决条件:默认的 Cygwin 安装和支持 git daemon 的 git 客户端)

Step 1: Open a bash shell

第 1 步:打开一个 bash shell

Step 2: In the directory /cygdrive/c/cygwin64/usr/local/bin/, create a file named "gitd" with the following content:

第二步:在/cygdrive/c/cygwin64/usr/local/bin/目录下,创建一个名为“gitd”的文件,内容如下:

#!/bin/bash

/usr/bin/git daemon --reuseaddr --base-path=/git --export-all --verbose --enable=receive-pack

Step 3: Run the following cygrunsrv command from an elevated prompt (i.e. as admin) to install the script as a service (Note: assumes Cygwin is installed at C:\cygwin64):

步骤 3:从提升的提示符(即以管理员身份)运行以下 cygrunsrv 命令以将脚本安装为服务(注意:假设 Cygwin 安装在 C:\cygwin64):

cygrunsrv   --install gitd                          \
            --path c:/cygwin64/bin/bash.exe         \
            --args c:/cygwin64/usr/local/bin/gitd   \
            --desc "Git Daemon"                     \
            --neverexits                            \
            --shutdown

Step 4: Run the following command to start the service:

第 4 步:运行以下命令启动服务:

cygrunsrv --start gitd

cygrunsrv --start gitd

You are done. If you want to test it, here is a quick and dirty script that shows that you can push over the git protocol to your local machine:

你完成了。如果你想测试它,这里有一个快速而肮脏的脚本,它表明你可以将 git 协议推送到你的本地机器:

#!/bin/bash

echo "Creating main git repo ..."
mkdir -p /git/testapp.git
cd /git/testapp.git
git init --bare
touch git-daemon-export-ok
echo "Creating local repo ..."
cd
mkdir testapp
cd testapp
git init
echo "Creating test file ..."
touch testfile
git add -A
git commit -m 'Test message'
echo "Pushing master to main repo ..."
git push git://localhost/testapp.git master

回答by poiuytrez

GitStackmight be your best choice. It is currently free (for up to 2 users) and open sourceat the time of writing.

GitStack可能是您的最佳选择。在撰写本文时,它目前是免费的(最多 2 个用户)并且是开源的。

回答by Daniel O

Here's a dedicated git server for windows: https://github.com/jakubgarfield/Bonobo-Git-Server/wiki

这是 Windows 的专用 git 服务器:https: //github.com/jakubgarfield/Bonobo-Git-Server/wiki

回答by David Arno

If you are working in a Windows environment, have you considered Mercurial? It is a distributed version control system like Git, but integrates far more neatly and easily with Windows.

如果您在 Windows 环境中工作,您是否考虑过Mercurial?它是一个类似于 Git 的分布式版本控制系统,但与 Windows 集成得更加简洁和轻松。

回答by isaac

If you get the error cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062: The service has not been started.after running the command:

如果cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062: The service has not been started.运行命令后出现错误:

cygrunsrv --start gitd

that means that you did not create the 'base-path' folder.

这意味着您没有创建“基本路径”文件夹。

Creating the folder '/git' and rerunning the command will fix this.

创建文件夹“/git”并重新运行该命令将解决此问题。

回答by Alex Burtsev

Installing CygWin is an overkill, read this tutorial on how to do it faster and native:

安装 CygWin 是一种矫枉过正,请阅读本教程,了解如何更快、更本地地安装:

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

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

回答by Matthew McCullough

I'm currently using cygwin's ssh daemon on Windowsto serve up and allow remote access to my repo. It works quite well, I have complete control over who accesses my repo by their ssh certificates, and the performance blazes, even over remote WAN and VPN links.

我目前在 Windows 上使用cygwin 的 ssh 守护程序来提供服务并允许远程访问我的存储库。它工作得很好,我可以完全控制谁通过他们的 ssh 证书访问我的 repo,甚至通过远程 WAN 和 VPN 链接也能控制性能。

Another solution is to use Gitosis. It is a tool that makes hosting repos much easier.

另一种解决方案是使用 Gitosis。它是一种使托管存储库变得更加容易的工具。

回答by Artem

Now msysGit supports git daemon ! It works fine (for me at least). I gonna try to make it run as service...

现在 msysGit 支持 git 守护进程!它工作正常(至少对我而言)。我会尝试让它作为服务运行......

回答by Henk

You do not need to host a service, you can also create a shared repository on a shared drive. Just create a bare repository. You can clone an existing repo into a shared one using: "git clone --bare --shared [source] [dest]". You can also init a new repository using "git init --bare --shared=all".

您不需要托管服务,您也可以在共享驱动器上创建共享存储库。只需创建一个裸存储库。您可以使用“git clone --bare --shared [source] [dest]”将现有仓库克隆到共享仓库中。您还可以使用“git init --bare --shared=all”来初始化一个新的存储库。

Henk

亨克

回答by Clokey

Have you considered using the cygwin layer? See this link.

您是否考虑过使用 cygwin 层?请参阅此链接