How to add parent directory to git repo

git

Solution

If your repository should only contain the `proj` folder with nothing else at the same level, then the proper way to do it is to make `proj` the repository. You do that by following those instructions, i.e. calling `git init` within the `proj` folder.

That way, when people clone your repository, they automatically get a folder with the same name as the repository which then contains all the stuff. For example:

git clone git@bitbucket.com/username/proj

This will automatically create a folder `proj` in which the repository contents are being placed. If you had everything in another subfolder now, they would have to `cd proj/proj` to actually get there. That’s why you probably shouldn’t add another directory level there.

However, if you want other folders in the repository beside `proj` (at the same level), then it might make sense to make the parent folder a repository and add the folders there. Note though, that usually, you would want to make one repository for each separate project. So if you have `proj` and `proj2`, you should make two repositories that each contain one project.

Problem

I am brand new to git so go easy. I have a project with the following structure: ``` ~/proj ~/proj/dir1 ~/proj/dir2 ``` I created a git repo (on Bitbucket) and I want to import all of proj/ into the repo (including proj). What is the right way to do this? All instructions I find tell you to `cd proj/; git init . ; git add *;` This will add each of the subdirectories (dir1, dir2) to the repo but does not add proj. How do I add proj and it's subdirectories? I was always able to do this in subversion but can't figure it out with git. Ideally when someone clones the project they will get proj/ and all of its subdirectories.

Original source