Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git从另一个目录克隆_Git_Git Clone - Fatal编程技术网

git从另一个目录克隆

git从另一个目录克隆,git,git-clone,Git,Git Clone,我正在尝试从另一个目录克隆repo 假设我在C:/folder1和C:/folder2 git clone [--template=<template_directory>] [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>] [--se

我正在尝试从另一个目录克隆repo

假设我在
C:/folder1
C:/folder2

git clone [--template=<template_directory>] [-l] [-s] [--no-hardlinks]
[-q] [-n] [--bare] [--mirror] [-o <name>] [-b <name>] [-u <upload-pack>]
[--reference <repository>] [--separate-git-dir <git dir>] [--depth <depth>]
[--[no-]single-branch] [--recursive|--recurse-submodules] [--]<repository>
[<directory>]


<repository>

    The (possibly remote) repository to clone from.
    See the URLS section below for more information on specifying repositories.
<directory>

    The name of a new directory to clone into.
    The "humanish" part of the source repository is used if no directory 
    is explicitly given (repo for /path/to/repo.git and foo for host.xz:foo/.git).
    Cloning into an existing directory is only allowed if the directory is empty.
我想将
folder1
中的工作克隆到
folder2

我应该在命令提示符中键入什么来执行此操作


似乎通常在克隆URL时提供的是一个URL而不是一个文件路径,然而,此时此刻我只是在练习并尝试使用Git。

使用
Git克隆c:/folder1 c:/folder2

git clone [--template=<template_directory>] [-l] [-s] [--no-hardlinks]
[-q] [-n] [--bare] [--mirror] [-o <name>] [-b <name>] [-u <upload-pack>]
[--reference <repository>] [--separate-git-dir <git dir>] [--depth <depth>]
[--[no-]single-branch] [--recursive|--recurse-submodules] [--]<repository>
[<directory>]


<repository>

    The (possibly remote) repository to clone from.
    See the URLS section below for more information on specifying repositories.
<directory>

    The name of a new directory to clone into.
    The "humanish" part of the source repository is used if no directory 
    is explicitly given (repo for /path/to/repo.git and foo for host.xz:foo/.git).
    Cloning into an existing directory is only allowed if the directory is empty.
git clone[--template=][-l][-s][--无硬链接]
[-q][-n][-bare][-mirror][-o][-b][-u]
[--reference][--separate git dir][--depth]
[-[no-]单分支][--递归|--递归子模块][-]
[]
要从中克隆的(可能是远程)存储库。
有关指定存储库的详细信息,请参见下面的URL部分。
要克隆到的新目录的名称。
如果没有目录,则使用源存储库的“humanish”部分
显式给定(repo for/path/to/repo.git和foo for host.xz:foo/.git)。
仅当目录为空时,才允许克隆到现有目录中。

它看起来很简单

14:27:05 ~$ mkdir gittests
14:27:11 ~$ cd gittests/
14:27:13 ~/gittests$ mkdir localrepo
14:27:20 ~/gittests$ cd localrepo/
14:27:21 ~/gittests/localrepo$ git init
Initialized empty Git repository in /home/andwed/gittests/localrepo/.git/
14:27:22 ~/gittests/localrepo (master #)$ cd ..
14:27:35 ~/gittests$ git clone localrepo copyoflocalrepo
Cloning into 'copyoflocalrepo'...
warning: You appear to have cloned an empty repository.
done.
14:27:42 ~/gittests$ cd copyoflocalrepo/
14:27:46 ~/gittests/copyoflocalrepo (master #)$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)
14:27:46 ~/gittests/copyoflocalrepo (master #)$ 
从:

对于git本机支持的本地存储库,可以使用以下语法:

/path/to/repo.git/

file:///path/to/repo.git/
这两个语法基本上是等价的,除了前者意味着——局部选项


如果路径中有空格,请用双引号将其括起来:

$ git clone "//serverName/New Folder/Target" f1/

这些对我都不管用。我正在windows上使用git bash。 发现问题在于我的文件路径格式

错:

git clone F:\DEV\MY_REPO\.git
正确:

git clone /F/DEV/MY_REPO/.git

这些命令是从您希望repo文件夹出现的文件夹中执行的。

值得一提的是,该命令在Linux上的工作方式类似:

git clone path/to/source/folder path/to/destination/folder

我在windows中使用git bash。最简单的方法是更改路径地址以使用正斜杠:

git clone C:/Dev/proposed 
附言: 在目标文件夹上启动git bash

克隆中使用的路径-->c:/Dev/provided


windows中的原始路径-->c:\Dev\proposed

使用路径本身对我不起作用

以下是在MacOS上对我最终起作用的内容:

cd ~/projects
git clone file:///Users/me/projects/myawesomerepo myawesomerepocopy
这也起到了作用:

git clone file://localhost/Users/me/projects/myawesomerepo myawesomerepocopy
如果我这样做,路径本身就起作用了:

git clone --local myawesomerepo myawesomerepocopy

您可以使用
git clone C:\folder1\.git folder2
。您需要从希望folder2出现的目录运行它。如果您在windows中,但它仍然不工作,则可能需要将`file:\`前置到存储库路径。看到这个@grahamesd,你真的不需要把一个网络文件夹映射成一个驱动器,因为GIT可以用这样的方式克隆它:
GIT clone//pc\u name/GIT
下面的命令在bash中运行:GIT clone F:\DEV\MY\u repo对于GIT bash,你可以使用反斜杠
//code>或双斜杠“\\”。但是没有一个斜杠。是的,OP的例子是Windows,但问题并没有标记Windows,所以我发帖希望能帮助Mac用户