Windows 局域网上的 Git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2230500/
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
Git on a Windows Lan
提问by pistacchio
My colleagues and I are thinking of giving git a try and see if we can easily move to it. We work on a Windows-only environment. On our own machines we already have git set up with mingw32 and SmartGit as gui client.
我和我的同事正在考虑尝试使用 git,看看我们是否可以轻松地转向它。我们在仅限 Windows 的环境中工作。在我们自己的机器上,我们已经使用 mingw32 和 SmartGit 作为 gui 客户端设置了 git。
Is there an easy approach based more on the concept of sharing folders than on the concept of "hosting server"? For example, we wanted to host a git repository on a folder shared on the lan, clone it on our machines and see how to push our changes back to that folder, merge them and so on.
是否有一种更基于共享文件夹概念而不是“托管服务器”概念的简单方法?例如,我们想在局域网共享的文件夹上托管一个 git 存储库,在我们的机器上克隆它,看看如何将我们的更改推送回该文件夹,合并它们等等。
Our first problem was cloning from the lan. Of course git doesn't recognize paths like \\mymachine\shared\repo
我们的第一个问题是从局域网克隆。当然 git 不识别路径\\mymachine\shared\repo
How to start with our approach? Is to doable? Any advice?
如何开始我们的方法?是否可行?有什么建议吗?
Thanks in advance.
提前致谢。
EDIT
编辑
As suggested, a command line approach worked. We also had to invert the slashes, so that git clone //machine/directory/repository
did the trick. Now, my colleague had a local copy working, made some changes... How to push them back to the shared folder?
正如所建议的,命令行方法有效。我们还必须反转斜线,这样git clone //machine/directory/repository
就可以了。现在,我的同事有一个本地副本工作,做了一些更改......如何将它们推回共享文件夹?
Push and Fetch work on local paths too, we're up and running with our tests. Thank you all!
Push 和 Fetch 也在本地路径上工作,我们已经启动并运行了我们的测试。谢谢你们!
采纳答案by Kit Roed
My advice sidesteps your efforts a bit, but I've been using Mercurial in exactly the same approach you've described here, and if it's not too much of a plan change, I'd encourage you to give using TortoiseHga try. Mercurial works with file path based repositories exactly the same way it works with "served" repositories (e.g. it will recognize \\server\shared_repo\repo_path
as a valid repository path to clone from.)
我的建议有点回避您的努力,但我一直在以与您在此处描述的完全相同的方法使用 Mercurial,如果计划没有太大变化,我鼓励您尝试使用TortoiseHg。Mercurial 处理基于文件路径的存储库的方式与处理“服务”存储库的方式完全相同(例如,它将识别\\server\shared_repo\repo_path
为要从中克隆的有效存储库路径。)
As an additional point, from what I can tell, Mercurial's Windows support is pretty far along, whereas git still has some fringe compatibility issues (although it appears that you've addressed many of the biggest challenges to using git on Windows already)
另外一点,据我所知,Mercurial 的 Windows 支持还很远,而 git 仍然存在一些边缘兼容性问题(尽管您似乎已经解决了在 Windows 上使用 git 的许多最大挑战)
回答by VonC
For a pure command-line solution, did you try
对于纯命令行解决方案,您是否尝试过
git clone file:///local/path/to/repo-name.git
In your case:
在你的情况下:
git clone file:///\mymachine/shared/repo.git
It should work just fine.
它应该工作得很好。
Update August 2014 (4 years later), Git 2.1
2014 年 8 月更新(4 年后),Git 2.1
Commit c2369bdby Eric Sunshine and Cezary Zawadka (czawadka
)means a simpler UNC path now work:
由 Eric Sunshine 和Cezary Zawadka ( czawadka
)提交的 c2369bd意味着现在可以使用更简单的 UNC 路径:
Windows: allow using UNC path for git repository
Windows:允许对 git 存储库使用 UNC 路径
Eric Sunshine fixed
mingw_offset_1st_component()
to return consistently "foo
" for UNC "//machine/share/foo
", cf this thread.
Eric Sunshine 固定
mingw_offset_1st_component()
返回一致的“foo
为 UNC”//machine/share/foo
“”,参见此线程。
So this should now work:
所以这现在应该工作:
git clone //mymachine/shared/repo.git
回答by Joel Lucsy
We use TortoiseGit. The URL's it accepts are //machinename/shared/repo.
我们使用 TortoiseGit。它接受的 URL 是 //machinename/shared/repo。
回答by DalSoft
My post has a step by step guide to creating a distributed git repository using a windows share. I've found that a windows share works fine for small projects.
我的帖子有使用 Windows 共享创建分布式 git 存储库的分步指南。我发现 Windows 共享适用于小型项目。
回答by Rayan Elmakki
"I have a few different computersthat I use at home and I wanted to set up GIT that I can access my code from any of them. It took me a bit because I was too used to working with a client-server model where I designate one machine as the "server" that holds the repository and everything else was a client. Instead, GIT seems to operate more like a merge tool and every local copy is its own "master." Once I understood that, it turns out that setting up GIT is very simple and just needs GIT itself and SSH".
“我在家里使用了几台不同的计算机,我想设置 GIT,以便我可以从其中任何一台计算机访问我的代码。这花了我一点时间,因为我太习惯于使用客户端 - 服务器模型指定一台机器作为保存存储库的“服务器”,其他所有东西都是客户端。相反,GIT 似乎更像是一个合并工具,每个本地副本都是它自己的“主”。一旦我明白了这一点,事实证明设置 GIT 非常简单,只需要 GIT 本身和 SSH”。
To read more you can check this link: http://blog.lazyhacker.com/2010/04/setting-up-git-for-home-network.html
要了解更多信息,您可以查看此链接:http: //blog.lazyhacker.com/2010/04/setting-up-git-for-home-network.html