Difference between #8 and #4 of Starting your Yii Project Reference Guide (with Git VCS in Linux)

unchanged
Title
Starting your Yii Project Reference Guide (with Git VCS in Linux)
unchanged
Category
Tutorials
unchanged
Tags
git, github, reference, guide, yii
changed
Content
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.

If you don't have Yii yet


~~~
[php]
$ git clone https://github.com/yiisoft/yii.git
~~~


start your project (being at root folder)


~~~
[php]
$ yii/framework/yiic webapp myproject
$ cd myproject
~~~

initialize git


~~~
[php]
$ git init
~~~


make git add empty directories to the repository


~~~
[php]
for i in $(find . -type d -regex ``./[^.].*'' -empty); do touch
$i"/.gitignore"; done;
~~~

(source [https://gist.github.com/18780](https://gist.github.com/18780 "git
script") )

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

~~~
[php]
git submodule add https://git.gitorious.org/lightopenid/lightopenid.git
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:
~~~
[php]
git submodule update --init
~~~
should fix it. Then you can update your repository and external ones with:

~~~
[php]
git pull && git submodule update --recursive
~~~

To remove a submodule:
~~~
[php]
git rm --cached protected/extensions/lightopenid
~~~

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

~~~
[php]
assets/*
!assets/.gitignore
protected/runtime/*
!protected/runtime/.gitignore
protected/data/*.db
~~~

Make your first commit


~~~
[php]
git commit -a "Initial version"
~~~

NowIf you are readywant to go!

#Keep in mind some database design best practices
[http://www.yiiframework.com/wiki/227/guidelines-for-good-schema-design](http://www.yiiframework.com/wiki/227/guidelines-for-good-schema-design
"Guidelines for good schema design")

#Use migration for tracking database changes
[http://www.yiiframework.com/doc/guide/1.1/en/database.migration](http://www.yiiframework.com/doc/guide/1.1/en/database.migration
"")
add your forked repo from github ( i.e.:
git@github.com:marcanuy/Comments-module.git ) from another repo (i.e.:
git://github.com/segoddnja/Comments-module.git)  to the extensions directory,
then:

~~~
[php]
$yii/framework/yiic migrate create myNewTablegit submodule add
git@github.com:marcanuy/Comments-module.git protected/Comments-module
cd protected/extensions/Comments-module
git remote add upstream git://github.com/segoddnja/Comments-module.git
~~~

Update database with new migrations after updating yourThen every
time you wish to get latest updates from the original repo
 you should do:
~~~
[php]
$yii/framework/yiic migratecd
protected/extensions/Comments-module
git pull upstream master
~~~

#Don't forgetNow you are ready to secure your app
[http://www.yiiframework.com/wiki/275/how-to-write-secure-yii-applications/](http://www.yiiframework.com/wiki/275/how-to-write-secure-yii-applications/
"Secure your app")
go!