Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7025193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:56:30+00:00 2026-05-27T23:56:30+00:00

Hoping someone might know the explanation for this inconsistent behavior. I have had this

  • 0

Hoping someone might know the explanation for this inconsistent behavior. I have had this problem both with public repos as well as my own project repos, but for example’s sake I’ll use the Facebook SDK from GitHub.

If I clone this repo, it checks out into a folder called php-sdk. This is pretty much to be expected, although the repo file listing at GitHub doesn’t show this folder.

If I clone it out as a submodule in another project (which would be a pretty common operation for an SDK like this) I just get the contents of the folder directly outputted into the directory I choose.

I have also had it happen that when I wrap all my project files in a directory and commit it into the repo, it sometimes doesn’t come out in this structure when cloned (same output as the submodule example above.) Changing the name prefix of the .git dir seems to change this, but does not have any effect on the outcome of the submodule command.

Is there a reason these commands all behave differently handling the first directory in the repo structure? Am I misunderstanding how to store my files inside a repo? I guess you could file this under minor nuisance, but I would love to get the conventions for this to make my repos more friendly for cloning.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:56:31+00:00Added an answer on May 27, 2026 at 11:56 pm

    Basically there is no ‘wrapping’ directory stored as part of the repository. Your expectations that there is one is what is misleading you. A Git repo is just, by default, the directory called .git. Your sandbox, or the stuff that is checked out, is placed at the same root level that the .git folder is located. When you make a clone it automatically checks out the master branch. The .git folder and the checkout is the actual root of your git workspace.

    By convention, Git will normally infer a name and create a directory for your workspace when you use the clone and git submodule add command. It will create the directory and then it places the git repo (that .git folder) and then checkout the master branch files into it. However, you could specify git clone <repo> . or git clone <repo> <target_dir> and Git will place the root of your repo and checkout anywhere you want.

    So if you created a repo like this:

    mkdir repo.git
    cd repo.git
    git init
    touch foo
    git add foo
    git commit -m "Initial commit"
    

    When you clone it later with git clone repo.git it is only by convention it is put into a subdirectory called repo that has a file called foo and a directory .git. However, repo is the root checkout directory, not the current directory (you can tell because it will have a .git directory in it). The directory you ran clone from will NOT be the directory that stores the .git or checkout directory. If you wanted that you would do git clone <repo> . and then you would see just the file called foo and a directory called .git and no directory called repo.

    If you want there always to be a directory called repo nesting all the source in then you would of created the repo like this:

    mkdir repo.git
    cd repo.git
    git init
    mkdir repo
    cd repo
    touch foo
    git add foo
    git commit -m "Initial commit"
    

    Then when you clone it by just using git clone <uri>/repo.git you’ll have a directory called repo that contains a directory .git and a directory called repo that has the foo file. In my opinion this is a layer of indirection that can be cumbersome (I know, I did it…once).

    Submodule’s are an entry in the main repo as simply a directory which contains another git repo at a certain checkout. When you init and update the submodule the first time it is basically just creating the directory reserved for the submodule by the main repo and then fetches that whole git repo and checkout into that directory. Since you should understand now that a git repo is just normally the .git directory and a checkout along side it it should be obvious why that directory would not also have a different wrapping directory in it. You basically named what directory the submodule should wrap in when you use the git submodule add <repo> [<target_dir>] command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is an open-ended quesiton, but I was hoping someone might have
I'm concerned that this might be working on an NP-Complete problem. I'm hoping someone
I am hoping someone might know the answer to this off the top. I
Hoping someone can clear this up for me. Let's say I have 2 globals:
I have a weird problem that I am hoping someone can help me with.
This has been a hard problem to diagnose and I was hoping someone could
I was hoping someone might help with a function that given two parameters: @param
I'm having some strange drawing artefacts that I'm hoping someone might be able to
Hoping someone can provide an answer with this, although it's not 100% programming related.
Hoping someone can shed some light on this: Do lookup tables need their own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.