Skip to Content

Git Cloning Without That Extra Subdirectory

An article posted
about development & git.
As presented by the incredible Fred LeBlanc.
now with 113 reads

Update, 1/5 @ 3:49pm — Showing my n00bness, Jeff correctly says that if you add an additional parameter of where to clone your repository, no subfolder will be made. So: git clone https://github.com/username/repo.git . to clone it to whatever the current directory is. That’s way easier. Thanks Jeff!

I’m still finding my sea-legs using Git, but I love what I’ve seen so far. One thing that’s always bothered me is that using git clone always creates a subfolder within the folder of where I mean to put my files. This is something I can manage on my local machine, but won’t work when I need to set up production to pull down new files.

So I set out to figure out how to get my repository without that annoying extra subdirectory, and it turns out it’s easier than I was expecting. It takes three steps.

  1. In a terminal window, navigate to the directory of where you’ll want to place the files. Once there, initialize git with git init
  2. Create a remote pointer to your git repository, for example, if you’re on Github, you’ll do something like this: git remote add origin https://github.com/username/repo.git, where origin is what you want to name the pointer (it can be anything you want), and the URL is that of the repository
  3. Finally, use git pull origin master to pull down your files, where origin is whatever you ended up naming your remote pointer, and master is the branch that you want to pull down

Check the contents of the folder that you’re in, and all of your files should be there, sans stupid automatically created subdirectory.

Recent Fredlines

See More

Fred LeBlanc is trying to make the web a better place. He develops, designs, writes, improves, constructs, invents, and creates (hopefully) interesting content and projects.

He’s reasonably well-known for his jQuery plugin, he co-runs a meet up for web folks and he’s been known to make a TextMate theme or two.

Learn More