3

I've some problem with Git, I'm unable to push all subfolder with a single push command

I have a project directory as below:

project
      |
      |--main
      |     |__dir1
      |     |     |__file1
      |     |     |__filen
      |     |        
      |     |__dir2
      |     |     |__file1
      |     |     |__filen
      |     |__dirn
      |           |__file1
      |           |__filen
      |    
      |--tools
      |       |--dir1
      |       |     |__file1
      |       |     |__filen
      |       |
      |       |__dir2
      |       |     |__file1
      |       |     |__filen    
      |       |
      |       |__dirn

With this structure I create a new local repository with following commands:

 cd project
 git init

then, from project folder I add, commit, and push all with:

 git add .
 git commit -m "First commit"
 git push origin -u master

the problem is that in my remote repo I found only the first level directories so i found only main and tools but none of folder inside.

currently I don't have any .gitignore inside the entire directory tree.

what I'm doing wrong ?

thank you very much

Update1:

to give more info, i use gogs as git server https://gogs.io/

Marco
  • 487
  • 2
  • 6
  • 25

2 Answers2

1

Not so trivial at first glance, you cannot simply add empty directories, but you can get over it with adding .gitkeep file into every empty directory with:

find . -type d -empty -exec touch {}/.gitkeep \;

The {} is replaced by each emptydir found by the find command, and becomes $1 to the shell (touch) command.
\; marks the end of the find's exec arguments. backslash "\" is to escape ";" sign to mark end of -exec command. Otherwise it would be treated as bash/shell terminator sign ";"

Karol Flis
  • 311
  • 2
  • 12
0

finally i found the problem root... there are some problems with directory permissions. With a simple chown/chmod everything work as expected.

Marco
  • 487
  • 2
  • 6
  • 25