I have a directory like below:
/var/tmp/main
.. plugin1
.... mysource.c
.. plugin2
.... mysource.c
.. plugin3
.... mysource.c
And I created a repository. After that, I applied the below:
$ cd /var/tmp/main
$ git init
$ echo "hello git plz work" >> README
$ git add README
$ git commit -m 'first commit works'
$ git remote add origin git@...../main.git
$ git push origin master
I also tried
$ git add .
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
#
# modified: folder1 (modified content)
# modified: folder2 (modified content)
# modified: folder3 (modified content)
# modified: folder4 (modified content)
# modified: folder5 (modified content)
# modified: folder6 (modified content, untracked content)
# modified: folder7 (modified content)
# modified: library (modified content, untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git commit -m 'Suggested by Stack experts'
$ git push
Tried also .gitignore
$ cat .gitignore
*.[oa]
*.pyc
*.gcda
*.gcno
*.la
*.lo
*.loT
*.sw[po]
*.tar.*
*~
.deps
.libs
ABOUT-NLS
INSTALL
Makefile
Makefile.in
aclocal.m4
autom4te.cache
autoregen.sh
compile
config.guess
config.h
config.h.in
config.log
config.rpath
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
stamp-h1
Same so far…
All set but after 14 hours I still do not see all of my directories in Git, I only see the README file showing.
How can I commit all? (following http://scottr.org/presentations/git-in-5-minutes/ )
Here is the simple method to add empty directories:
…etc..
…etc…
This is because, as mentioned in other answers git tracks files in directories, but ignores directories on their own. This also might be fixed/solved in the git add mechanism in more up to date versions (I vaguely remember them adding their own .gitignore files to empty directories), so I’d really recommend trying to upgrade to the highest git version you can for that and other benefites, your distro may provide by default an older version, as ubuntu and debian do.
Edit:
The above technique is designed for the minimal amount of disturbance of your working directories in order to get empty folders tracked. -Each- directory would in my examples get their own .gitignore file (you can have as many .gitignore files as you like, they are additive).
So at the end your folder structure would look like this:
And then you would add the .gitignore files as placeholders!
But let’s take a step back and try the opposite tactic:
Maximum visibility.
Go to any folder you want to add, e.g.
plugin1. Create a file in that folder, call itplaceholder.Now navigate to that folder from the command line, e.g.
cd /var/tmp/main/plugin1/andgit addthat placeholder file, e.g.git add placeholder. You’ve told git that you want that file tracked (if you typegit diffyou can review the “proposed” changes. It’ll tell you that it sees the file, but that it’s just an empty file, which is fine).Now commit the file:
git commit placeholder -m " Adding a Placeholder file."When you add any file, all the folders that contain that file, down to the main git folder, get added as well, so you’ll now have /plugin1/ tracked in git.
Go through, use
git add /path/to/fileon any of those (?) c source files you have, and then commit the changes, viagit commit /path/to/file. Generally, anything that’s pure text, it’s good to be added to the repository, of course.Finally: Be aware that
git statusis only designed to tell you about modified, tracked files, including newly added files. If there are no modifications, it’ll just give you mostly blank output.To see the files that -are- actually tracked by git, use
git ls-tree HEADwhich will only show you tracked files!For a clean start
Here is how I generally start a git repository.