Date post: | 08-May-2015 |
Category: |
Software |
Upload: | roberto-segura |
View: | 866 times |
Download: | 2 times |
Git for Joomla! development
+
BLOG:Email: [email protected]
About me● PLT member● CMS contributor● JBS & JSST member● PHP & JS developer● Freelance
Twitter: @phproberto
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
Version Control Systems
Nothing Copy & Paste Local VCS CVCS DVCS
Distributed Version Control Systems
● Easier to setup● Less data loss risk● Review changes locally● Better speed● Dev. Independency
DVCS benefits:
github● Extend functionalities● Save server management● Visual interface● Search issues / Google● Comments● Tag issues● Stats● Credits● Integrations (Travis, Jenkins..)
git & Joomla!
● Required to contribute● joomla/joomla-cms -> CMS● joomla-framework -> Framework● joomla-extensions -> Utilities● joomla-cms -> Light core● joomla-projects -> Parallel projects
Desired schema
local fork
upstream origin Your forkMain repo
Fork CMS repository
Fork view + clone URL
The terminal!
Why use terminal
● It works on all OS● You end using it anyway● You understand git● You see cli output
git aliases
https://gist.github.com/phproberto/5066462
Clone fork locally
git clone {fork-url}
Upstream server
Add upstream server
git remote add upstream {upstream-url}
git branches
http://git-scm.com/book/en/Git-Branching-What-a-Branch-Is
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
git merge
http://git-scm.com/book/en/Git-Branching-Branching-Workflows
Keep your main branch clean
● Usually “master” branch● CMS uses “staging”● git-3.x-dev for features
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
git log
git l (custom alias)
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”
git status
Staging
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
git add tricks
Add all files:git add -A
Add only new files:git add .
Add only modified files:git add -u
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”)
Push branch to your forkgit push origin fields-error
local fork
upstream origin
Your forkMain repo
fields-error
Create a pull request
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
Pull request code
● Always review code!● Avoid 10 commits for 10
lines (squash)● Github Coding Standards● Add minified/unminified
assets● Compile LESS
Be open to critique
● Improve as developer● Avoid being blamed● People invests time on you● Ask help / guidance● Learn for free!
Keep your PR up to date
● Add commits locally and push● Rebase before pushing● Squash if needed
git rebase
http://git-scm.com/book/en/Git-Branching-Rebasing
git rebase upstream/staging
git push origin fields-error --force
git rebase
http://git-scm.com/book/en/Git-Branching-Rebasing
NEVER rebase a collaborative branch!
Squash commitsgit rebase -i staging
Squash commitsResult:
Questions?
Thanks for watching