I was introduced to Kirby by my good friend Nils Hendriks. Since then i fell in love with it, mainly its architecture, templating and ease-of-use. Artminister is built on kirby, fully version controlled with git.
Kirby is a file-based CMS which can be used for small and mid-sized websites. No database means, it can be easily version controlled and updated to the latest version pretty easily. I will describe my process of setting up kirby and git.
- Basic Terminal Knowledge (MacOSX) or Command Prompt (WIN)
- SSH Access to your server
- Create a gitignore file to ignore .DS_Store or other files.
Clone the kirby repository
Use Terminal to navigate to your MAMP htdocs folder
Clone the repository using the following command
git clone git://github.com/bastianallgeier/kirbycms.git
Create a branch
The cloned repository is in its MASTER branch. We want this branch to be untouched so that kirby can be updated. So create a branch where you will start working on your new site
cd kirbycms git checkout -b mynewbranch
This will create a new branch "mynewbranch" and will update HEAD to set the specified branch as current branch.
Create a remote Repo
Create a remote repo in your server or in github. Now, go back to your local repository, and add the newly created remote repository so it tracks from the remote repository (live).
git remote add live https://github.com/username/remoterepo.git
Note: Remote "origin" is already used by git://github.com/bastianallgeier/kirbycms.git
You can view the remote repositories using
git remote -v
Clone the remote repo to your server
SSH in to your live webserver and clone the remote repository
git clone -b mynewbranch https://github.com/username/remoterepo.git ~/public_html
A bash file to push files to github and update the server
Create a bash file in your root folder, i have it named "update.sh"
kirbycms (ROOT) - assets - content - kirby - site - index.php - .gitignore - .htaccess - update.sh
In the update.sh file add the following
git commit -am "$1"; git push origin mynewbranch; ssh -p 22 email@example.com "cd ~/public_html; git pull origin mynewbranch; rm -rf site/cache/* " #Clears Cache
You can now call this bash file from the terminal using
bash update.sh "Commit Message here"
Edit : July 26, 2012
Update.sh doesnt have to be in the ROOT of your website. You can keep it anywhere. Just add the following line at the top of the file.
To update kirby, go to your local repository and switch to MASTER branch
git checkout master git pull origin master # Pull the master branch git checkout mynewbranch git merge master
This will merge the master branch with your "mynewbranch". Now your local copy is updated with the latest Master branch of kirby.
So here it is my kirby and git setup. It can be easily updated to the latest version or the dev version.
Working on dev version
You can switch to the DEV branch of kirbycms using
git checkout origin/dev
Now you're in the development branch of kirby and you can test out the latest features.
- Git Flow : Use git-flow if you are working with a bigger team