如何在Windows上设置和克隆远程git仓库? [英] How to setup and clone a remote git repo on Windows?

查看:907
本文介绍了如何在Windows上设置和克隆远程git仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何从Windows服务器上的git远程仓库签出,克隆或获取项目或代码?



存储库IP是: xxx.xx.xxx.xx ,源文件目录是 c:\repos\project.git



我习惯于SUSE Linux终端的命令行界面。我尝试了同样的方法,但它总是回复:

 致命:''/repo/project.git''看起来不是git存储库
致命的:无法从远程存储库读取。
请确保您拥有正确的访问权限

任何人都可以告诉我如何设置和克隆吗?

解决方案

从Windows机器上设置某种共享,你可以用git访问。 Git支持3种访问方法:ssh,远程文件系统或http。最后一个可能是最复杂的,所以我不会详细说明。前两个是:


  1. 在windows上设置ssh服务器。



    <你可以试试这个指南: http://www.timdavis.com.au/git/setting-up-a-msysgit-server-with-copssh-on-windows/ 。另请参阅此问题以获取更多选项。



    比你用克隆git clone username@xxx.xx.xxx.xx:/ c / git / path / to / repo (你会被要求输入密码)。



    这种方法的优点是安全(连接已加密,ssh服务器值得信赖),所以你可以使用它互联网。由于git服务器在访问期间在windows计算机上运行,​​因此您可以为高级安全策略设置钩子,控制其他进程等。

  2. 使用共享资源库Windows共享。

    在Linux主机上,您需要使用 smbmount 装入共享。这可能需要用户名和密码,具体取决于你如何设置权限。



    比你克隆 git clone / share / mountpoint / path / to / repo



    这可能比较容易设置,但它不是很安全,所以不应该在本地网络之外使用。同样在这种情况下,windows机器上的钩子将不会被执行(实际上git会尝试在Linux机器上执行它们,但它们要么不会在那里运行,要么无论如何都可以绕过),所以您不能应用高级安全。

一个特定的文件是不相关的,你需要给包含 .git 子目录或者到裸仓库的目录( path / to / repo >)。

Anybody know how to checkout, clone, or fetch project or code from a git remote repository on a Windows server?

Repository IP is: xxx.xx.xxx.xx, source file directory is c:\repos\project.git

I am used to the command line interface from a SUSE Linux terminal. I have tried the same kind of method but it always replies that

fatal: ''/repo/project.git'' does not appear to be a git repository
fatal: Could not read from remote repository..
Please make sure you have the correct access rights

Can anyone tell me how to setup and clone?

解决方案

You have to set up some kind of sharing from the windows machine, that you can access with git. Git supports 3 access methods: ssh, remote filesystem or http. The last one is probably most complicated, so I won't detail it. The first two are:

  1. Set up ssh server on windows.

    You can try this guide: http://www.timdavis.com.au/git/setting-up-a-msysgit-server-with-copssh-on-windows/. See also this question for some more options.

    Than you clone by git clone username@xxx.xx.xxx.xx:/c/git/path/to/repo (you will be asked for password).

    Advantage of this method is that it's secure (connection is encrypted and ssh server is trustworthy), so you can use it over internet. Since git server is running on the windows machine during access, you can set up hooks for advanced security policy, controlling other processes and such.

  2. Share the repository using windows sharing.

    Than on the linux host, you need to mount the share with smbmount. That might require username and password, depending on how you set the permissions.

    Than you clone by git clone /share/mountpoint/path/to/repo.

    This is probably easier to set up, but it is not very secure, so it shouldn't be used outside local network. Also in this case hooks on the windows machine won't be executed (in fact git will try to execute them on the Linux machine, but they either won't run there or can be bypassed anyway), so you can't apply advanced security.

A particular file is not relevant, you need to give path to the directory containing .git subdirectory or to the directory that is a bare repository (path/to/repo above).

这篇关于如何在Windows上设置和克隆远程git仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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