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

  • Home
  • SEARCH
  • 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 6751017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:52:36+00:00 2026-05-26T12:52:36+00:00

I have a directory like below: /var/tmp/main .. plugin1 …. mysource.c .. plugin2 ….

  • 0

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/ )

  • 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-26T12:52:36+00:00Added an answer on May 26, 2026 at 12:52 pm

    Here is the simple method to add empty directories:

    //create some empty, gitignore files.
    touch ./someDir/.gitignore
    touch ./someOtherDir/.gitignore
    

    …etc..

    git add ./someDir/.gitignore
    git add ./someOtherDir/.gitignore
    

    …etc…

    git commit -am "  Add empty project directories."
    

    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:

    /var/tmp/main
    .. plugin1
    .... mysource.c
    .... .gitignore
    .. plugin2
    .... mysource.c
    .... .gitignore
    .. plugin3
    .... mysource.c
    .... .gitignore
    

    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 it placeholder.

    Now navigate to that folder from the command line, e.g. cd /var/tmp/main/plugin1/ and git add that placeholder file, e.g. git add placeholder . You’ve told git that you want that file tracked (if you type git diff you 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/file on any of those (?) c source files you have, and then commit the changes, via git 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 status is 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 HEAD which will only show you tracked files!

    For a clean start

    Here is how I generally start a git repository.

    cd /path/to/project/
    git init
    echo "README" >> README
    git add .
    git commit -am "  Initial Commit of readme and files."
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method like below public List<aspnet_Roles> GetAllRoles() { var rolesList = _dbProfile.aspnet_Roles.ToList();
I have a set of files in a directory like below: File-MyFile.txt File-AnotherFile.txt File-ThirdFile.txt
I have a directory structure like the following; script.php inc/include1.php inc/include2.php objects/object1.php objects/object2.php soap/soap.php
let's say i have directory paths looking like this: this/is/the/basedir/path/a/include this/is/the/basedir/path/b/include this/is/the/basedir/path/a this/is/the/basedir/path/b In
When creating gems, I often have a directory structure like this: |--lib |-- helpers.rb
I have directory with > 1000 .html files, and would like to check all
I am a beginner in SVN.I have the SVN directory structure like this: |-trunk
I have a directory of files that I'd like to append file extension to
I have a directory of files that I would like to scan on a
I have a directory with files that look like this: 001_something.php 002_something_else.php 004_xyz.php 005_do_good_to_others.php

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.