1

I have a main_project which contain project1,project2,project3. I want to add project4 files into, I've run these commands, it creates the folder but as an empty folder :

git pull
# add the project4
git add .
git commit -m "test"
git push
phd
  • 82,685
  • 13
  • 120
  • 165
Amine Sehaba
  • 122
  • 6
  • Is everything in project 4 being ignored do to your .gitignore? – J Livengood Mar 20 '18 at 22:24
  • What does `git status` show? – Stephen Newell Mar 20 '18 at 22:24
  • What happens after you do the above commands? Do the folders have any files or are they empty? Note that [git cannot track empty folders](https://stackoverflow.com/questions/115983/how-can-i-add-an-empty-directory-to-a-git-repository). – Code-Apprentice Mar 20 '18 at 22:29
  • @Code-Apprentice it push the main_project and the project4 is empty (but in my local machine its not empty) – Amine Sehaba Mar 20 '18 at 22:33
  • Run `git status` and update your question to include the output of `git status` – Rafael Mar 20 '18 at 22:35
  • @StephenNewell when i run `git status` it show "nothing to commit" but if i run `git init` , `git add .` , `git commit -m "test" ` on project4 and execute `git status` again it show me that there is something to commit when i commit it and push it, it still an empty folder – Amine Sehaba Mar 20 '18 at 22:39
  • Do you have a `.gitignore` file? – Rafael Mar 20 '18 at 22:40

1 Answers1

0

If the project4 itself has a .git subfolder, that would means:

  • it is a Git repo,
  • a git add . from the parent project would only record a gitlink (special entry in the index), not the actual folder content.

If you don't need project4 folder history, simply remove the .git subfolder.

If you do need, consider referencing project4 through submodules.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250