-2

I pushed my files to git but the files within a subdirectory were not added. The folder appears blue with an arrow on it like so:

blue folder

And when you click on that folder nothing happens.
I followed the instructions on this website:

[how to add subdirectories in github][2]

I cd into the directory that is not up to date on git. I ran

git init -b master

I then ran

git add new-folder/

but that yielded the error:

fatal: pathspec 'latin/' did not match any files.  

I then guessed and ran

git add . && git commit -m 'a'

That yielded

[master (root-commit) c94b921] a
 511 files changed, 6344433 insertions(+)

I then ran

git push -u origin master

And got:

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Not really understanding the meaning of the -u flag I ran I then tried:

git push origin master

And got:

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

I then guessed and backed up to directory above

cd ..

And ran

git push origin master

And got:

Everything up-to-date

I refreshed the page on the github repository and no changes were made.

#########UPDATE

People are telling me that I need to use submodule. I just want to make sure that it's clear that I want only one repository. I have roughly 8 subdirectories and I find it very hard to believe that guthub's software would be so cumbersome that it cannot enable users to update changes to files in different subfolders with the click of one button. I want to set things up so that when I make changes in two different folders that changes from both folders are both updated when I hit git push

######### SECOND UPDATE

I deleted the .git folder in the subdirectory whose name is latin. I then ran

git add latin
git commit -m 'a'
git push -u origin master

which outputted:

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 240 bytes | 240.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:kylefoley76/latin_databases2.git
   b617974..a549a34  master -> master
branch 'master' set up to track 'origin/master'.

I then refreshed the page in github and although it said that the latin subdirectory was updated a minute ago, you still can't click on it and see the subfolders within in it.

bobsmith76
  • 160
  • 1
  • 9
  • 26
  • Its a `submodule` meaning that its a repository within a repository. So the parent repo can't control the repo within. You need to use commands from `git submodule -h` or cd into the folder and it will automatically switch the repo when you're in there. – Prav Jun 04 '22 at 23:42
  • But is it possible to make them all belong to one repository. For example, I have roughly 8 subfolders within the current folder that I'm having trouble with. Am I going to have to do 8 separate `git submodule -h` commands? – bobsmith76 Jun 04 '22 at 23:48
  • On the second part, Git doesn't understand folders. Git treats files paths as a key-value arrangement, `repo/latin` is a name, `/` doesn't mean anything. So if you need to have a empty folder in a Git repo, the convention is to add `.keep` file in the folder which then Git tracks – Prav Jun 04 '22 at 23:48
  • That really seems needlessly complex to me. – bobsmith76 Jun 04 '22 at 23:48
  • Git doesn't create submodules by default. For that you must run `git submodule init` within a folder or import another repo using `git submodule add git@github.com...` for example. – Prav Jun 04 '22 at 23:50
  • I think you can use `git submodule deinit` in that folder to undo that. – Prav Jun 04 '22 at 23:51
  • see update in the OP – bobsmith76 Jun 04 '22 at 23:59
  • Do you have a file called `.gitmodules` on the root of your repo? If you do open it. It will tell you which folders are submodules if any. No Git isn't cumbersome, its most likely you cloned a repo into another one and Git took it upon itself to embed the repo as a submodule assuming that's what your intentions were. – Prav Jun 05 '22 at 00:00
  • Can you provide the github repo? Is that image from GitHub or an IDE? – astrochun Jun 05 '22 at 00:09
  • @praveen No, I don't have a file named .gitmodules – bobsmith76 Jun 05 '22 at 00:22
  • So I think the issue here is that you have submodule set up on GitHub but not(?) locally. This SO might be of help: https://stackoverflow.com/questions/62056294/github-folders-have-a-white-arrow-on-them I think what you want to try to do is to de-initialized the submodule on GitHub, and then `git push` the folder. – astrochun Jun 05 '22 at 00:27
  • see update .... – bobsmith76 Jun 05 '22 at 01:25

2 Answers2

0
  1. Make sure that the names of these files are not written in the .gitignore file.
  2. Display the name of your remote repository using this command:
    git remote -v 
    
  3. git push name-of-your-repository master
    
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
TappedAsh
  • 1
  • 1
  • That didn't really help. The folder that I want to push is not in .gitignore and git remove -v simply informed me of the name of the repository and git push etc merely outputted 'everything up to date'. – bobsmith76 Jun 04 '22 at 23:55
0

I decided to delete the repository and start over. I'm pretty sure that when I tried it before that I did not have a .git file in the subfolder but maybe I'm wrong. This time around I deleted all hidden .git files and uploaded everything from scratch. One of the instructions that I was getting wrong was

git add 'readme.md'

Github really should alter that instruction because I assumed that since I didn't have a 'readme.md' file I didn't need to run it but by running

git add .

That seemed to add the files that I needed to add in the subdirectories.

bobsmith76
  • 160
  • 1
  • 9
  • 26