Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I'm new to git (and github). I work in Java and Python. Right now, I manage my projects in only one directory - let's call it Code and the folder is on my Desktop.

I want to group my projects by the language I code in. So, I want:

++ /Java/
++ /Python/

I do not know if Git would be happy with this or not. If it would be, what should I set my home directory to be?

And how should I manage it with my github account? For example, I create a new repo on GH for a new-project in Python (but I already have files on my local machine in /Code/Python/new-project), how should I about committing the files to GH making sure any other directories are not messed up with?


Just to be clear, I have unrelated projects in /Code/project_1, /Code/project_2, /Code/project_3 etc. But I want to arrange them as /Code/Java/project_1, /Code/Java/project_1, /Code/Python/project_1 etc.

share|improve this question

closed as not a real question by Jim G., Glenn Nelson, MichaelT, Dynamic, gnat Jun 12 '13 at 4:42

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Why would you mix together unrelated projects in one repository? It sounds like a VCS version of the God object anti-pattern – Izkata Jun 12 '13 at 1:07
I don't know why you think I am mixing projects in one repo. I have different projects in different folders and repos. Each project has its own repo. But some repos have code in Java, and some in Python. All those repos are in one folder. I want to organize those different, unrelated folders by language within a main folder. Is that possible? If yes, which folder should be my git directory? – Karan Goel Jun 12 '13 at 2:26
I think you need to clarify the question some more, then, because it seemed to me like you were asking about (for example) /Code/Python/project_1, /Code/Python/project_2, and /Code/Java/project_3 all existing in the repository checked out at /Code... – Izkata Jun 12 '13 at 2:32
To answer the small part of the question that seems clear - Version control 101: The VCS doesn't care at all what layout you use. It sees directories, text files, and binary files (sometimes with metadata like "executable" and so on). – Izkata Jun 12 '13 at 2:35
Don't lump unrelated code or projects together. If it is tightly related code in different languages git won't complain. Just make sure these things make sense being together. – Rig Jun 12 '13 at 2:56

2 Answers 2

up vote 2 down vote accepted

Git, for all that, cares not one whit about what your directory structure looks like. It can be infinitely nested, one flat broad file space in a single directory, or whatever. It doesn't care if you have symlinks pointing at files between directories, it doesn't even particularly care if you have symlinks pointing outside the project tree.

It also doesn't care at all what language the files are written in, or whether they are programs, data, images, etc.

GIT DON'T CARE. Git is a honey badger in that regard.

The only caveat here, if a directory is empty, Git won't pick it up to add to the repo. This is why you see so many bare directories except for a .gitkeep file. The name of this file matters not to Git, it's just a convention adopted by us Gits. :)

So, organize your project however makes sense to you. The only major conventions that seem to go across the board are having a readme and license file in the project root. Your project's particular environment may require more, but then we're getting into more specifics.


Now, to address your specific question: Just make a repo for each project; Git, nor Github, care:


Meanwhile, over on github, you just have these projects as individual repo depots:

The instructions for dealing with existing local repo after you make your Github repo are right there on the post-creation page you get from Github:

On local machine:

$ cd /Code/Python/new_project
$ git add --all -v # assuming you do know you want everything checked in
$ git commit -m 'some message'
$ git remote add origin

(If you had Github create the README and/or .gitignore (I never do this))

$ git pull origin master

(Fix any merge conflicts)

$ git push origin master

Boom-de-yada! Everything is up on Github.

share|improve this answer

I don't know if it's considered good practice or not, but I'm fairly sure git allows creating a new local repository in any arbitrary directory, which then can be added to github via the standard "git remote add" command or the relevant menus in the GUI application.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.