git clone z innego katalogu

Próbuję sklonować repo z innego katalogu.

Powiedzmy, że mam jeden repo w C:/folder1 i C:/folder2

Chcę sklonować pracę w folder1 do folder2.

Co wpisać w wierszu polecenia, aby to zrobić?

Wydaje się, że często podczas klonowania podany jest adres URL, a nie ścieżka do pliku, jednak w tej chwili po prostu ćwiczę i próbuję się przyzwyczaić do Gita.

Author: Omer Dagan, 2014-01-10

7 answers

cd /d c:\
git clone C:\folder1 folder2

Z dokumentacji dla git clone:

Dla lokalnych repozytoriów, również wspieranych natywnie przez git, można użyć następujących składni:

/path/to/repo.git/

file:///path/to/repo.git/

Te dwie składnie są w większości równoważne, z wyjątkiem pierwszej implikuje opcję -- local.

 107
Author: Chris,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-10 14:03:49

Żadne z nich nie zadziałało. Używam git-bash na windows. Okazało się, że problem był z formatowaniem ścieżki pliku.

Źle:

git clone F:\DEV\MY_REPO\.git

Poprawny:

git clone /F/DEV/MY_REPO/.git

Te polecenia są wykonywane z folderu, w którym ma się pojawić folder repo.

 8
Author: J.M.I. MADISON,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-01-21 15:16:50

To takie proste, na jakie wygląda.

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 #)$ 
 6
Author: Andreas Wederbrand,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-10 13:28:35

Jeśli masz miejsce na ścieżce, owiń ją podwójnymi cudzysłowami:

$ git clone "//serverName/New Folder/Target" f1/
 4
Author: Yar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-05-24 15:44:39

Warto wspomnieć, że polecenie działa podobnie na Linuksie:

git clone path/to/source/folder path/to/destination/folder
 4
Author: Yasir Jan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-12-13 09:29:42

Użyj git clone 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.
 2
Author: Bleeding Fingers,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-10 13:33:38

Używam git-bash w windows.Najprostszym sposobem jest zmiana adresu ścieżki, aby mieć ukośniki do przodu:

git clone C:/Dev/proposed 

P. S: Uruchom git-bash w folderze docelowym.

Ścieżka użyta w clone - - - > c:/Dev/proposed

Oryginalna ścieżka w windows - - - > c:\Dev\proposed

 0
Author: Mahmoud,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-01-31 04:04:16