2

My Wordpress site is version-controlled with Git, including the wp-content/plugins/ folder. Now there is a plugin (wp-editormd) that comes with its own Git repository, wp-content/plugins/wp-editormd/vendor/jaxsonwang/wp-settings-api-class/ (with .git/ inside) . Git treats it as a submodule, which is undesired. I am worried that Git-ignoring it could break the plugin or the plugin's update mechanism. How can I tell Git that it should treat the directory like a normal directory?

Marco Eckstein
  • 4,448
  • 4
  • 37
  • 48

1 Answers1

0

I am worried this might break something

The only thing it break is the history inside the submodule folder, which will be gone.

If it is a submodule (recorded in the .gitmodules), a git submodule deinit is in order.

If not, a git rm SubmoduleFolder first, (no trailing /), is enough, in order to remove the gitlink (special entry in the index), as illustrated here.

If it was not added, simply removing the nested .git folder is enough.

Then you can add, commit and push that folder, as a regular one.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I may misunderstand you. But the main Git project (my wordpress install) has no knowledge of the `SubmoduleFolder` yet, so there is no `.gitmodules` entry or gitlink. Only when I `git add --all` will Git warn about "adding embedded git repository" and then treat it as such. – Marco Eckstein Mar 22 '20 at 00:58
  • @MarcoEckstein No submodule: good. But you still need `git rm SubmoduleFolder` first, (no trailing `/`) to remove the reference to the nested git repository (because if the nested `.git/` folder): even without a .gitmodules, Git would still treat it as a "gitlink", a reference to another repository root tree. – VonC Mar 22 '20 at 01:02
  • If I `git rm SubmoduleFolder` before `git add --all`, I get `fatal: pathspec 'SubmoduleFolder' did not match any files`. If I do it afterwards, I get `fatal: could not lookup name for submodule 'SubmoduleFolder'`. If I `git rm --cached SubmoduleFolder` afterwards, I get `error: the following file has staged content different from both the file and the HEAD: SubmoduleFolder`. I can force removal, but then `SubmoduleFolder/**/*` will not be version-controlled. – Marco Eckstein Mar 22 '20 at 01:26
  • 1
    @MarcoEckstein Sure: just deleted the nested .git folder, and Git will treat it as a regular folder. I have edited the answer accordingly. – VonC Mar 22 '20 at 01:29