PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/system/guide/kohana/tutorials/git.md

https://bitbucket.org/seyar/kinda.local
Markdown | 129 lines | 79 code | 50 blank | 0 comment | 0 complexity | 0575ae4fd2722525e1b90028475d487a MD5 | raw file
  1. <http://kohanaframework.org/guide/tutorials.git>
  2. Provide links to some git tutorials.
  3. ### Creating a New Application
  4. [!!] The following examples assume that your web server is already set up, and you are going to create a new application at <http://localhost/gitorial/>.
  5. Using your console, change to the empty directory `gitorial` and run `git init`. This will create the bare structure for a new git repository.
  6. Next, we will create a [submodule](http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html) for the `system` directory. Go to <http://github.com/kohana/core> and copy the "Clone URL":
  7. ![Github Clone URL](http://img.skitch.com/20091019-rud5mmqbf776jwua6hx9nm1n.png)
  8. Now use the URL to create the submodule for `system`:
  9. git submodule add git://github.com/kohana/core.git system
  10. [!!] This will create a link to the current development version of the next stable release. The development version should almost always be safe to use, have the same API as the current stable download with bugfixes applied.
  11. Now add whatever submodules you need. For example, if you need the [Database] module:
  12. git submodule add git://github.com/kohana/database.git modules/database
  13. After submodules are added, they must be initialized:
  14. git submodule init
  15. Now that the submodules are added, you can commit them:
  16. git commit -m 'Added initial submodules'
  17. Next, create the application directory structure. This is the bare minimum required:
  18. mkdir -p application/classes/{controller,model}
  19. mkdir -p application/{config,views}
  20. mkdir -m 0777 -p application/{cache,logs}
  21. If you run `find application` you should see this:
  22. application
  23. application/cache
  24. application/config
  25. application/classes
  26. application/classes/controller
  27. application/classes/model
  28. application/logs
  29. application/views
  30. We don't want git to track log or cache files, so add a `.gitignore` file to each of the directories. This will ignore all non-hidden files:
  31. echo '[^.]*' > application/{logs,cache}/.gitignore
  32. [!!] Git ignores empty directories, so adding a `.gitignore` file also makes sure that git will track the directory, but not the files within it.
  33. Now we need the `index.php` and `bootstrap.php` files:
  34. wget http://github.com/kohana/kohana/raw/master/index.php
  35. wget http://github.com/kohana/kohana/raw/master/application/bootstrap.php -O application/bootstrap.php
  36. Commit these changes too:
  37. git add application
  38. git commit -m 'Added initial directory structure'
  39. That's all there is to it. You now have an application that is using Git for versioning.
  40. ### Adding Submodules
  41. To add a new submodule complete the following steps:
  42. 1. run the following code - git submodule add repository path for each new submodule e.g.:
  43. git submodule add git://github.com/shadowhand/sprig.git modules/sprig
  44. 2. then init and update the submodules:
  45. git submodule init
  46. git submodule update
  47. ### Updating Submodules
  48. At some point you will probably also want to upgrade your submodules. To update all of your submodules to the latest `HEAD` version:
  49. git submodule foreach 'git checkout master && git pull origin master'
  50. To update a single submodule, for example, `system`:
  51. cd system
  52. git checkout master
  53. git pull origin master
  54. cd ..
  55. git add system
  56. git commit -m 'Updated system to latest version'
  57. If you want to update a single submodule to a specific commit:
  58. cd modules/database
  59. git pull origin master
  60. git checkout fbfdea919028b951c23c3d99d2bc1f5bbeda0c0b
  61. cd ../..
  62. git add database
  63. git commit -m 'Updated database module'
  64. Note that you can also check out the commit at a tagged official release point, for example:
  65. git checkout 3.0.6
  66. Simply run `git tag` without arguments to get a list of all tags.
  67. ### Removing Submodules
  68. To remove a submodule that is no longer needed complete the following steps:
  69. 1. open .gitmodules and remove the reference to the to submodule
  70. It will look something like this:
  71. [submodule "modules/auth"]
  72. path = modules/auth
  73. url = git://github.com/kohana/auth.git
  74. 2. open .git/config and remove the reference to the to submodule\\
  75. [submodule "modules/auth"]
  76. url = git://github.com/kohana/auth.git
  77. 3. run git rm --cached path/to/submodule, e.g.
  78. git rm --cached modules/auth
  79. **Note:** Do not put a trailing slash at the end of path. If you put a trailing slash at the end of the command, it will fail.