Starting your Yii Project Reference Guide (with Git VCS in Linux)

  1. Getting Yii from Github
  2. Working with your project

I've found useful to have a step by step reference guide to work with Git with most used commands, feel free to update it with useful information you may find interesting too.

Getting Yii from Github

$ git clone

Working with your project

Start your project

(being at root folder)

$ yii/framework/yiic webapp myproject
$ cd myproject
Initialize git
$ git init
Make git add empty directories to the repository
for i in $(find . -type d -regex ``./[^.].*'' -empty); do touch $i"/.gitignore"; done;

(source )

Adding third-party extensions

Adding a yii extension repository inside your repo at a specific path (e.g. we will add in 'protected/extensions/lightopenid')

git submodule add protected/extensions/lightopenid

This creates the file .gitmodules in your root folder which tracks all your modules data.

if for some reason (older git versions, cloning from another location) you end up with an empty directory where a foreign repository should be:

git submodule update --init

should fix it. Then you can update your repository and external ones with:

git pull && git submodule update --recursive

To remove a submodule:

git rm --cached protected/extensions/lightopenid
Ignoring files

Edit .gitignore file in root folder and add dirs/files you don't want to be in git repo Use ! to negate the pattern:

Adding your own forked repo from github as an extension

If you want to add your forked repo from github ( i.e.: ) from another repo (i.e.: git:// to the extensions directory, then:

git submodule add protected/Comments-module
cd protected/extensions/Comments-module
git remote add upstream git://

Then every time you wish to get latest updates from the original repo you should do:

cd protected/extensions/Comments-module
git pull upstream master
Make your first commit
git commit -a "Initial version"

Now you are ready to go!

16 0
Viewed: 41 370 times
Version: 1.1
Category: Tutorials
Written by: marcanuy
Last updated by: marcanuy
Created on: Feb 20, 2012
Last updated: 12 years ago
Update Article


View all history

Related Articles