Top Banner
Git for Joomla! development +
40

Git for joomla! development #JAB14

May 08, 2015

Download

Software

Roberto Segura

How to use git to contribute to the Joomla! CMS development
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Git for joomla! development #JAB14

Git for Joomla! development

+

Page 2: Git for joomla! development #JAB14

BLOG:Email: [email protected]

About me● PLT member● CMS contributor● JBS & JSST member● PHP & JS developer● Freelance

Twitter: @phproberto

Page 3: Git for joomla! development #JAB14

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

Page 4: Git for joomla! development #JAB14

Version Control Systems

Nothing Copy & Paste Local VCS CVCS DVCS

Page 5: Git for joomla! development #JAB14

Distributed Version Control Systems

● Easier to setup● Less data loss risk● Review changes locally● Better speed● Dev. Independency

DVCS benefits:

Page 6: Git for joomla! development #JAB14

github● Extend functionalities● Save server management● Visual interface● Search issues / Google● Comments● Tag issues● Stats● Credits● Integrations (Travis, Jenkins..)

Page 7: Git for joomla! development #JAB14

git & Joomla!

● Required to contribute● joomla/joomla-cms -> CMS● joomla-framework -> Framework● joomla-extensions -> Utilities● joomla-cms -> Light core● joomla-projects -> Parallel projects

Page 8: Git for joomla! development #JAB14

Desired schema

local fork

upstream origin Your forkMain repo

Page 9: Git for joomla! development #JAB14

Fork CMS repository

Page 10: Git for joomla! development #JAB14

Fork view + clone URL

Page 11: Git for joomla! development #JAB14

The terminal!

Page 12: Git for joomla! development #JAB14

Why use terminal

● It works on all OS● You end using it anyway● You understand git● You see cli output

Page 13: Git for joomla! development #JAB14

git aliases

https://gist.github.com/phproberto/5066462

Page 14: Git for joomla! development #JAB14

Clone fork locally

git clone {fork-url}

Page 15: Git for joomla! development #JAB14

Upstream server

Page 16: Git for joomla! development #JAB14

Add upstream server

git remote add upstream {upstream-url}

Page 17: Git for joomla! development #JAB14

git branches

http://git-scm.com/book/en/Git-Branching-What-a-Branch-Is

Page 18: Git for joomla! development #JAB14

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

Page 19: Git for joomla! development #JAB14

git merge

http://git-scm.com/book/en/Git-Branching-Branching-Workflows

Page 20: Git for joomla! development #JAB14

Keep your main branch clean

● Usually “master” branch● CMS uses “staging”● git-3.x-dev for features

Page 21: Git for joomla! development #JAB14

git fetch vs git pull

git fetch upstreamgit merge upstream/staging

git fetch = download local copy

git pull upstream staging

git pull download and merge remote content

merge manually

Page 22: Git for joomla! development #JAB14

git log

Page 23: Git for joomla! development #JAB14

git l (custom alias)

Page 24: Git for joomla! development #JAB14

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 messagesgit l --grep=”internet explorer”

Page 25: Git for joomla! development #JAB14

git status

Page 26: Git for joomla! development #JAB14

Staging

Page 27: Git for joomla! development #JAB14

Your first commitEnsure that you are in a clean (and updated) branchgit checkout staging

Create a new branch:git checkout -b fields-error

{edit files on your IDE}

Staging files:git add templates

Page 28: Git for joomla! development #JAB14

git add tricks

Add all files:git add -A

Add only new files:git add .

Add only modified files:git add -u

Page 29: Git for joomla! development #JAB14

Committing changesCommit 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”)

Page 30: Git for joomla! development #JAB14

Push branch to your forkgit push origin fields-error

local fork

upstream origin

Your forkMain repo

fields-error

Page 31: Git for joomla! development #JAB14

Create a pull request

Page 32: Git for joomla! development #JAB14

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

Page 33: Git for joomla! development #JAB14

Pull request code

● Always review code!● Avoid 10 commits for 10

lines (squash)● Github Coding Standards● Add minified/unminified

assets● Compile LESS

Page 34: Git for joomla! development #JAB14

Be open to critique

● Improve as developer● Avoid being blamed● People invests time on you● Ask help / guidance● Learn for free!

Page 35: Git for joomla! development #JAB14

Keep your PR up to date

● Add commits locally and push● Rebase before pushing● Squash if needed

Page 36: Git for joomla! development #JAB14

git rebase

http://git-scm.com/book/en/Git-Branching-Rebasing

git rebase upstream/staging

git push origin fields-error --force

Page 37: Git for joomla! development #JAB14

git rebase

http://git-scm.com/book/en/Git-Branching-Rebasing

NEVER rebase a collaborative branch!

Page 38: Git for joomla! development #JAB14

Squash commitsgit rebase -i staging

Page 39: Git for joomla! development #JAB14

Squash commitsResult:

Page 40: Git for joomla! development #JAB14

Questions?

Thanks for watching