GitHub: Move .git to the parent directory
During development, we follow a specific file and folder structure. It’s common that things change during development. And in some cases, it’s necessary to move .git to the parent directory. This post shows how to achieve that.
When I started developing WordPress plugins, I’ve only pushed them to the plugin repository using SVN. Later, I started pushing them to GitHub as well to enable others to review and to contribute to my plugins. The plugins in the WordPress.org repository using the following structure:
plugin-slug
|-- assets/
|-- branches/
|-- tags/
|-- trunk/Initially, I’ve only tracked and pushed the content of trunk to GitHub. This was the file and folder structure of my plugin:
plugin-slug
|-- assets/
|-- branches/
|-- tags/
|-- trunk/
|-- .git/Recently, I learned how to use Travis CI. Thus, I added all the needed files to the root folder of my plugin. This lead to the following structure:
plugin-slug
|-- assets/
|-- branches/
|-- tags/
|-- trunk/
|-- .git/
|-- .eslintrc
|-- .travis.yml
|-- composer.json
|-- package.json
|-- phpcs.xml.distMove .git to the parent directory
- Rename the folder
trunktotrunk_old - Create the folder
trunkwithintrunk_oldand move all files from thetrunk_oldfolder totrunk - Move all other files and folders into
trunk_old - Move all files and folders from
trunk_oldinto the root folder - Delete the folder
_trunk - Commit your changes
This is the structure of my plugin after the change:
plugin-slug
|-- assets/
|-- branches/
|-- tags/
|-- trunk/
|-- .git/
|-- .eslintrc
|-- .travis.yml
|-- composer.json
|-- package.json
|-- phpcs.xml.dist