Problems commiting my bedrock project to source control (git)


I have trouble commiting my work done with the bedrock stack. I’m not able to add any changes in the theme folder to a commit. This is what I end up with:

Changes to be committed:
(use “git reset HEAD …” to unstage)

modified: composer.json
modified: composer.lock

Changes not staged for commit:
(use “git add …” to update what will be committed)
(use “git checkout – …” to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)

modified: web/app/themes/cpkg (modified content, untracked content)

I’ve done all my work in web/app/themes/cpkg, but I’m not able to stage those changes for a commit. I’ve also tried git add -A to no avail.

I would appreciate some help to get me going. Thank you.

You can’t add the folder? git add web/app/themes/cpkg ?

Unfortunately, it results in the same state. Nothing is added.

Seems like git thinks there is a submodule or another git repo. Did you remove the .git folder from the theme after you cloned it?

I have now removed .git folder. Now, on the other hand, web/app/themes/cpkg is not even tracked. Git does not see it as part of this repository. I’m just left with:

Changes to be committed:
(use “git reset HEAD …” to unstage)

modified: composer.json
modified: composer.lock

My changes in web/app/themes/cpkg are not seen in git.

@kalenjohnson, you were right that git treated web/app/themes/cpkg as a submodule that was not even reachable (greyed out cpkg icon in Github repository).

I’m a bit confused now. Any idea where I go from here?

Add the theme folder to your repository now

Thank you Kalen, I just reinitialized my repository and added everything again, this time with .git folder removed from the theme directory. All is good now. Much appreciated!

Btw. Is it always necessary to remove .git folder from the theme file after cloning it? I’m building this particular theme off Roots. Does Roots documentation mention that .git should be removed after cloning it or is it just a’common’ thing to do - asking out of curiosity?

It’s necessary if you want to have a theme as part of your repository in a subfolder. A lot of people probably also just clone the theme on its own outside of a WP site folder structure. At that point it doesn’t matter much if you keep it or not.

1 Like