jamestagal / edtechdesigner

A professional blog site of Benjamin Waller
https://edtechdesigner.io
0 stars 1 forks source link

Git and your theme/compendium #4

Closed jimafisk closed 2 years ago

jimafisk commented 2 years ago

When I initiated a git repo in this project folder I noticed that git didn't see theme/compendium files/folders so I couldn't add them. At first when I run the command git status the folders do not appear as folder/files but now I see an M next to the folder in VS code which I think stands for Modified. But for instance when doing git add - A these folders don't get added! Below is what is printed.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
        modified:   themes/compendium (modified content, untracked content)

Therefore I can only push up the files I have added/changed to my github repo. Is this by design? If I understand it, all the theme folders and files need to be included into my Github repo for me to be able to publish/host it somewhere? If you could clarify this or how I can get them up to my repo would be great.

When i didn't some research online I thought the issue may have been because it works like a submodule? but I think it isn't a submodule. So I am confused here so if you could clarify this it would be great.

jimafisk commented 2 years ago

You might have been running into issues with submodules (e.g. a project with its own .git folder nested within another project with a .git folder). I intended to design the Theming API in Plenti specifically to avoid this, so might need to double check that's working. Did you add the theme originally with: plenti new site edtechdesigner --theme=https://github.com/plenti-themes/compendium?

Whatever the reason, it seems the theme was not being tracked in git. Running the following cleared things up:

git rm --cached themes/compendium/

Should be fixed in https://github.com/jamestagal/edtechdesigner/pull/6

jamestagal commented 2 years ago

Hi Jim, Thank you for replying. From memory I used the following command

plenti theme add git@github.com:plenti-themes/compendium

I ran your suggested command and then did a git add -A and got the following warning:

warning: adding embedded git repository: themes/compendium
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint: 
hint:   git submodule add <url> themes/compendium
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:   git rm --cached themes/compendium
hint: 
hint: See "git help submodule" for more information.

then running git status it says:

❯ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
        modified:   themes/compendium (modified content, untracked content)

What should I do at this point? will doing the regular commit to git then push to repo work? I see the warning message about submodule so to add all themes/compendium files now to git and then Github, do I need to use git submodule add themes/compendium ?

jimafisk commented 2 years ago

That's a bummer, so after running the plenti theme add is there a themes/compendium/.git folder? If so, just delete it manually: sudo rm -R themes/compendium/.git. If not, try adding the theme files like this: git rm --cached themes/compendium/.

You could also just merge the pull request I created and that should clear things up: https://github.com/jamestagal/edtechdesigner/pull/6

jamestagal commented 2 years ago

yes so there was but now after deleting the .git files manually as you have suggested the .git folder isn't there but after doing a git status git doesn't see themes/compendium/ saying "nothing to commit, working tree clean" ... shouldn't git now see these files as untracked content? I'm confused....anyway I could merge the pull request you suggested....but I have never done a merge before.. but happy to try...Is it straight forward? Which option should I take based on the screenshot below? Screen Shot 2021-12-29 at 10 17 34 pm

jimafisk commented 2 years ago

So if you deleted the .git folder and the files still aren't tracking, you probably need to run the following (this is what I had to do on my end too when I cloned your repo):

git rm --cached themes/compendium/

To merge the pull request you can just leave the "create a merge commit" option and click the green "merge pull request" button. If you want a cleaner git history "squash and merge" them first so there are less commits, but it'll get you to the same place.

jamestagal commented 2 years ago

Thanks Jim. That did the trick! running the following git rm --cached themes/compendium/ Thank you for this.