ChatGPT解决这个技术问题 Extra ChatGPT

Change name of folder when cloning from GitHub?

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.

What did you mean by 'gems'?
@Milan probably ruby gems: ruby-lang.org/en/libraries

l
lfender6445

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


If you want to avoid an additional folder layer you can replace signin with .
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...] <repository> [<directory>], so we see that git clone repo_url my_directory should work, as the above answer correctly shows.
@Marged what did you mean by "If you want to avoid an additional folder layer... ?"
@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 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!
M
Michael Leiss
git clone <Repo> <DestinationDirectory>

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


g
gprathour

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

d
double-beep

Here is one more answer from @Marged in comments

Create a folder with the name you want Run the command below from the folder you created git clone .


J
Josh

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"