Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Git for joomla! development #JAB14

1,605 views

Published on

How to use git to contribute to the Joomla! CMS development

Published in: Software
  • Be the first to comment

Git for joomla! development #JAB14

  1. 1. Git for Joomla! development +
  2. 2. BLOG:Email: me@phproberto.com About me ● PLT member ● CMS contributor ● JBS & JSST member ● PHP & JS developer ● Freelance Twitter: @phproberto
  3. 3. What is git? ● Distributed Version Control System (DVCS) ● Compatible with all OS ● For team or single developers ● Record changes to files ● Revert files back ● Review changes over time ● See who changed what? ● Detect issue source
  4. 4. Version Control Systems Nothing Copy & Paste Local VCS CVCS DVCS
  5. 5. Distributed Version Control Systems ● Easier to setup ● Less data loss risk ● Review changes locally ● Better speed ● Dev. Independency DVCS benefits:
  6. 6. github ● Extend functionalities ● Save server management ● Visual interface ● Search issues / Google ● Comments ● Tag issues ● Stats ● Credits ● Integrations (Travis, Jenkins..)
  7. 7. git & Joomla! ● Required to contribute ● joomla/joomla-cms -> CMS ● joomla-framework -> Framework ● joomla-extensions -> Utilities ● joomla-cms -> Light core ● joomla-projects -> Parallel projects
  8. 8. Desired schema local fork upstream origin Your forkMain repo
  9. 9. Fork CMS repository
  10. 10. Fork view + clone URL
  11. 11. The terminal!
  12. 12. Why use terminal ● It works on all OS ● You end using it anyway ● You understand git ● You see cli output
  13. 13. git aliases https://gist.github.com/phproberto/5066462
  14. 14. Clone fork locally git clone {fork-url}
  15. 15. Upstream server
  16. 16. Add upstream server git remote add upstream {upstream-url}
  17. 17. git branches http://git-scm.com/book/en/Git-Branching-What-a-Branch-Is
  18. 18. git branch / git br http://git-scm.com/book/en/Git-Branching-Branching-Workflows git branch cool-branch Create a branch: Create and enter in a branch: git checkout -b cool-branch Delete a merged branch: git branch -d cool-branch Delete branches even not merged: git branch -D cool-branch Default list branches
  19. 19. git merge http://git-scm.com/book/en/Git-Branching-Branching-Workflows
  20. 20. Keep your main branch clean ● Usually “master” branch ● CMS uses “staging” ● git-3.x-dev for features
  21. 21. git fetch vs git pull git fetch upstream git merge upstream/staging git fetch = download local copy git pull upstream staging git pull download and merge remote content merge manually
  22. 22. git log
  23. 23. git l (custom alias)
  24. 24. git log tricks git l libraries/joomla/form/field.php log for a specific file/folder: search commits from one user: git l --author=”Roberto” search in commits messages git l --grep=”internet explorer”
  25. 25. git status
  26. 26. Staging
  27. 27. Your first commit Ensure that you are in a clean (and updated) branch git checkout staging Create a new branch: git checkout -b fields-error {edit files on your IDE} Staging files: git add templates
  28. 28. git add tricks Add all files: git add -A Add only new files: git add . Add only modified files: git add -u
  29. 29. Committing changes Commit staged changes: git commit -m ‘[imp] Code style fixes’ Always review status: git status Undo last commit without losing changes: Amend files to last commit: git commit --amend -C HEAD (alias “git amend”) git reset --soft HEAD^ (alias “git undolast”)
  30. 30. Push branch to your fork git push origin fields-error local fork upstream origin Your forkMain repo fields-error
  31. 31. Create a pull request
  32. 32. Pull request message ● Informative title ● Describe the issue ● Add screenshots (it’s free!) ● Add testing instructions ● Document features ● Comment if it’s a WIP ● Mention people if you need help
  33. 33. Pull request code ● Always review code! ● Avoid 10 commits for 10 lines (squash) ● Github Coding Standards ● Add minified/unminified assets ● Compile LESS
  34. 34. Be open to critique ● Improve as developer ● Avoid being blamed ● People invests time on you ● Ask help / guidance ● Learn for free!
  35. 35. Keep your PR up to date ● Add commits locally and push ● Rebase before pushing ● Squash if needed
  36. 36. git rebase http://git-scm.com/book/en/Git-Branching-Rebasing git rebase upstream/staging git push origin fields-error --force
  37. 37. git rebase http://git-scm.com/book/en/Git-Branching-Rebasing NEVER rebase a collaborative branch!
  38. 38. Squash commits git rebase -i staging
  39. 39. Squash commits Result:
  40. 40. Questions? Thanks for watching

×