Search code examples
gitgithubphpstorm

How to push public GitHub repo to private repo using PhpStorm?


I'm using PhpStorm to create a custom WordPress plugin. I cloned the CMB2 repo from GitHub into my plugin directory and saved the directory as CMB2. The files and directory are saved on my local machine without issue, and the WordPress local instance has no problem finding files required from the CMB2 directory.

I then committed my custom plugin to a private GitHub repo that I host. The CMB2 directory was part of the commit. However, the private repo only shows the directory name without any files contained therein. As such, when I install the plugin to a production WordPress instance, all required files in the CMB2 directory fail because CMB2 is empty.

I did git status on the CMB2 folder and shows that it was committed. What other steps should be taken to ensure the contents of CMB2 are properly committed?


Solution

  • When you clone a repository using git, it is put under a separate repository. From your description, it seems like your plugin resides in one git repository, and the CMB2 resides in a different nested one. So when you push, changes done to your plugin code goes to your GitHub repository, but changes in the CMB2 don't go anywhere.

    You could check where the repository root is using the git rev-parse --show-toplevel command. Run it inside CMB2 folder, and then inside your plugin folder. They will most likely return you different roots.

    If ti is the case, and you have two repositories, but still you want to include CMB2 contents into your primary repo, delete the CMB2/.git folder.

    But do you really need to include CMB2 code into your plugin? Seems there are better ways e.g. https://github.com/CMB2/CMB2/issues/624