699

When I clone something from Github, it creates a folder with the same name as the app on my computer. Is there a way to change the name?

For example, doing this clone creates a long "sign-in-with-twitter" folder:

git clone https://github.com/sferik/sign-in-with-twitter.git

I know I can rename the folder after, but I'm wondering if there's a way to rename it as it comes in by adding an option at the end of the statement. For example,

git clone https://github.com/sferik/sign-in-with-twitter.git  as 'signin'

the problem is that I'm cloning some apps multiple times in order to tweak some of the settings to get it to work, and if there's a problem, I delete the folder. But, I'm worried that some of the gems remain installed even though I've deleted the folder.

Milan
  • 1,743
  • 2
  • 13
  • 36
Leahcim
  • 40,649
  • 59
  • 195
  • 334

5 Answers5

1308

You can do this.

git clone https://github.com/sferik/sign-in-with-twitter.git signin

# or

git clone git@github.com:sferik/sign-in-with-twitter.git signin

refer the manual here

random-forest-cat
  • 33,652
  • 11
  • 120
  • 99
MLN
  • 13,728
  • 1
  • 17
  • 15
  • 62
    If you want to avoid an additional folder layer you can replace `signin` with `.` – Marged Jul 09 '18 at 11:37
  • @Marged that should be its own answer by freng. Hope the Homer doing good by the way. – lopezdp May 02 '19 at 00:19
  • 1
    I tried the RTFM approach and failed (hence why I'm here), but if you run `git clone --help` it will give you something like this: `git clone [--very-many-options...] []`, so we see that `git clone repo_url my_directory` should work, as the above answer correctly shows. – Purplejacket Sep 26 '19 at 18:46
  • @Marged, u should add your comment as one of the answer – Bhawna Jain May 13 '20 at 17:32
  • 1
    @Marged what did you mean by *"If you want to avoid an additional folder layer... ?"* – Milan Feb 10 '21 at 01:37
  • 3
    @Milan Usually all files go into a folder with the name of the repo. You can leave this folder out and store the files in the current folder – Marged Feb 10 '21 at 16:22
  • 1
    @Marged Oh, now, I got it. So, basically, it will download the contents of the repo in the current directory without creating a new directory (having the same name as the name of the repo). Thanks a lot! – Milan Feb 12 '21 at 20:15
78
git clone <Repo> <DestinationDirectory>

Clone the repository located at Repo into the folder called DestinationDirectory on the local machine.

Michael Leiss
  • 5,395
  • 3
  • 21
  • 27
17

In case you want to clone a specific branch only, then,

git clone -b <branch-name> <repo-url> <destination-folder-name>

for example,

git clone -b dev https://github.com/sferik/sign-in-with-twitter.git signin
gprathour
  • 14,813
  • 5
  • 66
  • 90
13

Here is one more answer from @Marged in comments

  1. Create a folder with the name you want
  2. Run the command below from the folder you created

    git clone <path to your online repo> .
    
double-beep
  • 5,031
  • 17
  • 33
  • 41
Bhawna Jain
  • 709
  • 10
  • 27
8

Arrived here because my source repo had %20 in it which was creating local folders with %20 in them when using simplistic git clone <url>.

Easy solution:

git clone https://teamname.visualstudio.com/Project%20Name/_git/Repo%20Name "Repo Name"

Josh
  • 4,009
  • 2
  • 31
  • 46