Can I git clone into a directory without cloning the project name as a directory (using bitbucket)?

24,960
git clone [repository] [local path]

If your working directory is your desired destination, simply put a .

$ git clone [email protected] .
Share:
24,960

Related videos on Youtube

Bms85smb
Author by

Bms85smb

I'm Front end developer/web designer, connoisseur of the outdoors, and aspiring adrenaline junkie...

Updated on September 18, 2022

Comments

  • Bms85smb
    Bms85smb over 1 year

    I'm a small business and for the most part only use git locally to track history then SFTP the files to the remote server.

    I now have a much larger more complicated build that to be set up properly requires a production, a staging, and a development server.

    I'm trying to set up git so I can merge changes from development and push/pull to the staging environment for deployment testing, then again to production.

    So far, I've installed git on production and development. I've also created a Repo via Bitbucket and commit/pushed the contents of my httpdocs folder to master. I thought this would mean I can simply clone then branch directly into my httpdocs folder on development.

    However, when I tried to pull these files into the development environement to make the development branch it included a folder with my project name(I never created this folder). I ended up with httpdocs/MyProjectName/Files

    My questions are:

    1. Did I do something wrong in setup?
    2. Is there a way to configure git so it knows I want the files not the containing directory?
    3. Can I clone in a way that only pulls the contents of MyProjectName but not the directory?

    I don't want my workflow to include pull then copy to httpdocs.

    • skarface
      skarface over 10 years
      are there files in httpdocs that aren't in your repo?
    • rockit
      rockit over 10 years
      I initially thought the OP misspelled "gitbucket" - turns out there's an actual project behind it.
    • Bms85smb
      Bms85smb over 10 years
      @skarface no there aren't
    • Bms85smb
      Bms85smb over 10 years
      @Isxek I did make a typo. I'm referring to bitbucket.org
  • Alf
    Alf almost 8 years
    Note: the directory you want to clone into, here called [local_path], must be empty
  • Bionix1441
    Bionix1441 over 3 years
    This works for one project level, how about if I have two folders I want to skip?
  • dhudson
    dhudson over 3 years
  • Bionix1441
    Bionix1441 over 3 years
    Thank you, the sparsecheckout would not work for me, since I am using maven plugin for Jenkins, and I only specify the URL of the repository to clone. May be the easiest solution is to remove the second wrapping folder.