77

Used git clone [url] to clone an open source project but it cloned to the

C:\Documents and Setings\$USER\project

What I wanted to do is clone the project to C:\project. I don't want to have duplicate project clones on my local machine.

How do I go about moving it to that location or deleting the existing repository(hopefully that's a correct term) and cloning it again?

I assume after deleting I should use something like the following to clone it to the desired location?

$ git clone [url] C:\project

PaulG
  • 13,871
  • 9
  • 56
  • 78
GitNewb
  • 771
  • 1
  • 5
  • 3

5 Answers5

82

Just move it :)

command line :

move "C:\Documents and Setings\$USER\project" C:\project

or just drag the folder in explorer.

Git won't care where it is - all the metadata for the repository is inside a folder called .git inside your project folder.

Shervin Asgari
  • 23,901
  • 30
  • 103
  • 143
deanWombourne
  • 38,189
  • 13
  • 98
  • 110
  • 4
    The only complication would be if you cloned from the moved clone because the second clones remember the path to their source. Then configurations of the second clones had to be be fixed. (Sorry for my English ;) – pepr Apr 25 '12 at 14:01
36

You can just delete that directory that you cloned the repo into, and re-clone it wherever you'd like.

tbthorpe
  • 773
  • 1
  • 6
  • 12
  • 2
    how to delete the clone repostory? The right click 'remove' option is greyed out. – zar Jun 19 '12 at 00:11
  • 5
    You're probably long gone by now, but for future readers of this question (it's the first listing for a Google search of "undo git clone"), make sure you are no longer inside that mistakenly cloned directory in your git bash window. (ie, type `cd ..` or whatever directory you'd like to move to.) – Jaime Oct 08 '13 at 19:09
18

You could try this via SSH: rm -rf foldernamehere

rayryeng
  • 102,964
  • 22
  • 184
  • 193
deanflory
  • 181
  • 1
  • 2
  • this is what I was looking for, thank you! For future readers of this -r is recursive and -f is force! I foolishly just tried rm... which even in the man page says "rm does not remove directories" – Robert Houghton Feb 07 '20 at 16:50
  • I was attempting to use rm -d for the same purpose (an llvm git clone directory) and it refused to budge. rm -r did it! – wide_eyed_pupil Mar 16 '22 at 08:59
5

I'm assuming you're using Windows, and GitBASH.

You can just delete the folder "C:...\project" with no adverse effects.

Then in git bash, you can do cd c\:. This changes the directory you're working in to C:\

Then you can do git clone [url] This will create a folder called "project" on C:\ with the contents of the repo.

If you'd like to name it something else, you can do git clone [url] [something else]

For example
cd c\:
git clone git@github.com:username\repo.git MyRepo

This would create a folder at "C:\MyRepo" with the contents of the remote repository.

carleton
  • 734
  • 1
  • 5
  • 9
3
  1. Go to working directory where you project folder (cloned folder) is placed.
  2. Now delete the folder.
  3. in windows just right click and do delete.
  4. in command line use rm -r "folder name"
  5. this worked for me
Naveen Mittal
  • 95
  • 1
  • 8