3

I am trying to add an existing Java project from a workspace to my git repository.

I'm using git version 1.8.3.2 on Linux.

I use this command:

git init/committed/remote origin/pushed

However, the src directory is only appearing as a greyed out empty folder.

How do I add a folder with subfolders to my github repository?

This is what it looks like. Notice 'src' is greyed out and un-clickable.

enter image description here

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
user884786
  • 33
  • 1
  • 4
  • After `git init`, did you add everything to the repo? (`git add .`?) – simont Aug 19 '13 at 02:15
  • Yep, I did, I can see everything on the "master-branch" but I can't submerge and explore the folders because they're grayed-out and isn't clickable. – user884786 Aug 19 '13 at 02:19
  • `bin` and `src` appear to be sub-repositories, not part of the same git repository. Is this what you intend? – simont Aug 19 '13 at 02:23
  • Look [here](https://github.com/Codesane/Simple-Chat-Application/commit/4635d0b2c11ae9d791af4afc091256882fdfad0c) at `src` and `bin`. They say "subproject commit". Read [this](http://stackoverflow.com/questions/7124483/difference-between-subprojects-and-submodules-in-git), [this](http://longair.net/blog/2010/06/02/git-submodules-explained/) and [the pro-git book](http://git-scm.com/book/ch6-6.html) to understand what a submodule is. It's not browsable because those directories are other git repositories. – simont Aug 19 '13 at 02:26

3 Answers3

3

src and bin are git submodules. They're not browsable because they are only pointers to other git repositories - they're not really "folders".

To add everything in a directory and subdirectories to git in one command, you can use git add ., which recursively adds.

Section 6 of the Pro Git book explains what a submodule is.

Assuming you do not want submodules, you can fix your repository like this:

cd <project> # Go to the projects root
rm -rf .git  # Remove all git information (keeping your code). 
cd src       # and repeat for src and bin
rm -rf .git
cd ../bin
rm -rf .git
cd ..        # now, back in the projects root
git init     # Make a git repository
git add .    # Add everything to it
git commit -m 'Initial commit'
git remote add github <github-url>
git push -f github # Force push to github, to overwrite everything we had before. 

Note that this will destroy the git repos in src and bin!!

I'm pretty sure this is what you want to do.

simont
  • 68,704
  • 18
  • 117
  • 136
0

To add *.* files and folders do it as follow:

  1. Navigate within your terminal/dos window to the the root folder of your project and use the command:

git init

git add .

git commit -m "This is my commit"

git push origin master

BTW: you can find more simplified details in the following tutorial: Import an existing, unversioned code project to an empty repository

Community
  • 1
  • 1
MaveRick
  • 1,181
  • 6
  • 20
  • For some reason it feels like I did just that when I followed the other guys instructions, and for some reason his worker instead of this one. Thanks for your input though! – user884786 Aug 19 '13 at 02:46
0

You should follow this guide: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

joninx
  • 1,775
  • 6
  • 31
  • 59