I was editing a theme I had downloaded and was using Git to track changes. Normally, it is quite easy to use Git and a remote repository to duplicate development across machines, but without checking in the entire ghost installation into the repository I had extreme difficulties getting cross-machine development.
In the end, I have found a solution that works and wanted to share it with anyone that might be having the same issues. The basic gist of it is that for each development machine you use the ghost-cli to install a fresh local ghost installation, and using .gitignore only track the files within your theme folder.
So, to develop on a new machine you would:
Create a new folder
Use the ghost-cli to install a new local ghost
Init .git
Add your remote repository
Pull in your changes
Start ghost
Here is the .gitignore file I’ve used to allow this:
Note if you’ve already been using git with a theme and have checked in files related to the ghost installation that is giving you an error when you try to pull the repository to a separate machine… you may need to just rip out the theme folder into a fresh Ghost Installation with that .gitignore file in place. For my own project I was unable to retroactively fix the Ghost installation, even with git rm --cached everything in the repository except the theme folder.
What’s your reasoning for commiting the Ghost code to git (i.e. the versions folder)? Could you not use content/themes/superawesometheme as the entrypoint to the git repo?
That way setup would be along the lines of
ghost install local
cd content/themes
git clone https://github.com/tryghost/casper casper-git
Ahh yes, that is perhaps an even better solution. I’m so used to initializing git at the root of a project I never thought of moving further down the tree.
Note that the .gitignore I provided also ignores the /versions directory, in fact ignores everything but theme folders
@ErikAGriffin I also prefer to create the repo at the root of the project as I do with all other frameworks, static sites or non web projects in general so changing it for just theme development just doesn’t feel right. Thanks for sharing
In this case the root of your project is your theme directory, after all it’s the theme that you are creating and sharing rather than the entirety of your local Ghost install Each theme is its own project.
Good point although I think it’s really relative to the developer and or just personal preference. I have one local install and work on multiple themes from that one install. For me personally the only reason I would break it up into two separate installs is if I did in fact need to share that repository with another dev or the owner for some reason but that will almost never happen for me.
Again just wanted to say thank you to Erik for being nice enough to share.