Say I have a bare repository on my local machine at ./new-bare.git.
What is the correct way to clone it to another location on my machine?
Asked
Active
Viewed 1.1k times
10
Omer Dagan
- 13,031
- 15
- 41
- 59
-
Possible duplicate of [git clone from another directory](http://stackoverflow.com/questions/21045061/git-clone-from-another-directory) – frlan Aug 16 '16 at 08:55
-
1@frlan Different question- I'm referring to cloning from bare repositories, as emphasized in the header – Omer Dagan Aug 16 '16 at 09:06
-
bare / non-bare should not make any difference – frlan Aug 16 '16 at 09:11
2 Answers
19
There is no difference in cloning from a not bare repository:
/tmp> mkdir foo
/tmp> git init --bare foo
Initialized empty Git repository in /tmp/foo/
/tmp> git clone /tmp/foo /tmp/baa
Cloning into '/tmp/baa'...
warning: You appear to have cloned an empty repository.
done.
frlan
- 6,698
- 3
- 26
- 70
-
I'm was a little confused with the use of `--local` but I guess your answer works for my simple case. 10X – Omer Dagan Aug 16 '16 at 09:17
7
git clone path_to_new-bare.git new_destination
Shravan40
- 7,746
- 5
- 27
- 45
-
It's worth mentioning that this appears to only work when the folder name ends with `.git` (as in the example). Apart from that, much nicer than the accepted answer, thanks :) – Daniel Veihelmann Mar 11 '21 at 11:38