Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git subfolder missing on push

Tags:

git

push

gogs

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/

like image 263
Marco Avatar asked Apr 21 '26 01:04

Marco


1 Answers

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 ";"

like image 127
Karol Flis Avatar answered Apr 23 '26 20:04

Karol Flis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!