在Windows中托管Git存储库 [英] Hosting Git Repository in Windows

查看:94
本文介绍了在Windows中托管Git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前有什么方法可以在Windows中托管共享的Git存储库?我知道您可以在Linux中配置Git服务:

  git daemon 

是否有本地Windows选项,缺少共享文件夹,无法托管Git服务?



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

解决方案

这里有一些步骤可以让git守护进程在Windows下运行:

(先决条件:一个默认的Cygwin安装和一个支持git守护进程的git客户端)

strong>:打开bash shell



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

 #!/ bin / bash 

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

第3步:从提升的提示符(即,运行以下命令)运行以下cygrunsrv命令(注意:假设Cygwin安装在C:\cygwin64):

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

第4步:运行以下命令以启动服务:
$ b cygrunsrv --start gitd b

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

 #!/ bin / bash 

echoCreating main git repo ...
mkdir -p /git/testapp.git
cd / git / testapp。 git
git init --bare
touch git-daemon-export-ok
echoCreating local repo ...
cd
mkdir testapp
cd testapp
git init
echo创建测试文件...
touch testfile
git add -A
git commit -m'测试消息'
回声推送主到主回购...
git push git://localhost/testapp.git主


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:

git daemon

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

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.

解决方案

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

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

Step 1: Open a bash shell

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

#!/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):

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:

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:

#!/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

这篇关于在Windows中托管Git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆