33

You're doing it wrong! Git it right!

Embed Size (px)

DESCRIPTION

Source code management and version control are absolutely essential to a successful software and web development project, especially when working with a team of developers. If your development workflow does not include Git, you're doing it wrong! Git it right! Git was first developed in 2005 by Linus Torvalds (yes, THE Linus Torvalds) as a distributed system for managing the development of the Linux kernel. Today, Git is used by companies and organizations large and small. According to the official Git webiste (http://git-scm.com/), Git is used Google, Micorosoft, Facebook, Twitter, and LinkedIn, just to name a few. Even the Joomla CMS and Joomla Platform teams now use Git. In this presentation, Cory Webb discusses Git and how his company uses Git to manage their web development workflow. He will go over some basic Git commands that every developer should know, as well as cover some popular tools for using Git locally and for hosting Git repositories. He will also open a discussion about how to overcome the limitations of Git, primarily when it comes to managing changes in the database between development and production servers.

Citation preview

Page 1: You're doing it wrong! Git it right!
Page 2: You're doing it wrong! Git it right!

manoscrafted.com/git-it-right.pdf

Page 3: You're doing it wrong! Git it right!

Who am I?

● Working with Joomla/Mambo since 2003● Founded Manos (formerly Cory Webb Media,

LLC) in 2008● Author of Beginning Joomla Website

Development (Wrox 2009)

Page 4: You're doing it wrong! Git it right!

Who are you?

● Developers/Programmers● Designers● Integrators

Page 5: You're doing it wrong! Git it right!

Agenda

● Why version control?● Intro to Git● Git Basics● Git Clients● Git Repository Hosting● Using Git for Joomla Projects● Questions

Page 6: You're doing it wrong! Git it right!

Why version control?

● Less of this: “I'm going to be working on template.css today, so nobody touch it!”

● More of this: “Let's all work on template.css today and use our version control system to merge our changes at the end of the day!”

Page 7: You're doing it wrong! Git it right!

Why version control?

● Easier to work as a team● Snapshots of your code at various stages of

development● Branching, staging and experimentation● Ability to revert back to previous versions

Page 8: You're doing it wrong! Git it right!

Intro to Git

● Offi cial website: http://git-scm.com● Distributed version control system● Enables team collaboration● Free and open source (GPLv2 license)● Used by Joomla, Google, Facebook, Microsoft,

Twitter, LinkedIn, Netfl ix, etc....● Seamlessly branch and merge code changes● Work locally

Page 9: You're doing it wrong! Git it right!

Intro to Git

● Multiple backups● Custom workflows● Data assurance● Code staging

Page 10: You're doing it wrong! Git it right!

Git Basics | Commands

● git clone

● git init● git status● git add . ● git commit -m “Comment about commit”

● git push● git pull● git merge

Page 11: You're doing it wrong! Git it right!

Git Basics | git clone

● Clone an existing Git repository● Creates an exact copy of the repository● Changes can be shared between the original

and the clone

● http://git-scm.com/docs/git-clone

Page 12: You're doing it wrong! Git it right!

Git Basics | git init

● Initialize a new git repository● Create a new project from scratch

● http://git-scm.com/docs/git-init

Page 13: You're doing it wrong! Git it right!

Git Basics | git status

● Returns the current status of the repository● Displays list of new, modified, and deleted files● Displays list of changes staged for commit

● http://git-scm.com/docs/git-status

Page 14: You're doing it wrong! Git it right!

Git Basics | git add

● Add changes to the staging area● Stage modifications (new files and changed

files) to be committed to the repository

● http://git-scm.com/docs/git-add

Page 15: You're doing it wrong! Git it right!

Git Basics | git commit

● Commits staged changes to the repository● Add a comment using -m “Comment”● Stage changes using -a after git commit

● http://git-scm.com/docs/git-commit

Page 16: You're doing it wrong! Git it right!

Git Basics | git push

● Updates remote repositories with local repository

● http://git-scm.com/docs/git-push

Page 17: You're doing it wrong! Git it right!

Git Basics | git pull

● Fetches a remote repository or local branch and merges changes with the local repository into the current branch

● http://git-scm.com/docs/git-pull

Page 18: You're doing it wrong! Git it right!

Git Basics | git merge

● Merges 2 or more development histories together

● http://git-scm.com/docs/git-merge

Page 19: You're doing it wrong! Git it right!

Git Basics | .gitignore

● File that specifies files within your project that Git should ignore

● Using the git status command will not list files from the .gitignore file

● Files listed will never be staged for commit or committed

● http://git-scm.com/docs/gitignore

Page 20: You're doing it wrong! Git it right!

Git Clients | Mac

● GitHub for Mac - Free - mac.github.com● Tower - $59 - www.git-tower.com● Gitbox - $9.99 / Free - www.gitboxapp.com● GitX - Free - gitx.laullon.com● SourceTree - Free - www.sourcetreeapp.com● Git-Cola - Free - http://git-cola.github.com/● SmartGit - $79 / Free - www.syntevo.com/smartgit

Page 21: You're doing it wrong! Git it right!

Git Clients | Windows

● GitHub for Windows - Free - windows.github.com● Git Extensions - Free -

code.google.com/p/gitextensions● Git-Cola - Free - http://git-cola.github.com/

● SmartGit - $79 / Free - www.syntevo.com/smartgit● TortoiseGit - Free - http://code.google.com/p/tortoisegit/

Page 22: You're doing it wrong! Git it right!

Git Clients | Linux

● Git-Cola - Free - http://git-cola.github.com/● SmartGit - $79 / Free -

www.syntevo.com/smartgit

Page 23: You're doing it wrong! Git it right!

Git Repository Hosting

● GitHub.com● BitBucket.org● BeanstalkApp.com● Assembla.com● CodebaseHQ.com● BareGit.com● Gitorious.org – RoR Git repo hosting app

Page 24: You're doing it wrong! Git it right!

Using Git for Joomla Projects

● Getting started● Establish your workflow● Deployment● Database issues

Page 25: You're doing it wrong! Git it right!

Git for Joomla | Getting Started

● Initialize the root directory of your Joomla project with 'git init' in your local web server (MAMP)

● Install Joomla● Set up your '.gitignore' file to specify files you don't

want to track● Add your files to the repository with 'git add .'● Commit your new files to the repository with 'git

commit -m “Initial commit”'

Page 26: You're doing it wrong! Git it right!

Git for Joomla | Getting Started

● Set up remote hosting for your repository● Push your local repository to the remote hosting● Each developer clones the repository to their

local systems

● TIP: Ignore the configuration.php file and let that be specific to each developer's local repo.

Page 27: You're doing it wrong! Git it right!

Git for Joomla | Establish workflow

● Subversion-style Workflow

Image from git-scm.com

Page 28: You're doing it wrong! Git it right!

Git for Joomla | Establish workflow

● Integration Manager Workflow

Image from git-scm.com

Page 29: You're doing it wrong! Git it right!

Git for Joomla | Establish workflow

● Dictator and Lieutenants Workflow

Image from git-scm.com

Page 30: You're doing it wrong! Git it right!

Git for Joomla | Deployment

● BeanstalkApp.com enables easy deployment to development, staging, and production servers

● Overwrite existing code files with the master repository once it is deemed ready for deployment

Page 31: You're doing it wrong! Git it right!

Git for Joomla | Database Issues

● Git does not track changes to a MySQL database

● Probably using different databases for each developer, the development server, staging server and the production server

● Development usually involves changing the database (adding articles, menu items, modules, etc. in Joomla)

● How do we deal with changes across so many different databases?

Page 32: You're doing it wrong! Git it right!

Git for Joomla | Database Issues

● Option 1: Point all instances of Joomla to the same remote database.

● Option 2: Manually track changes.● Option 3: Use a database synchronization tool such as

red-gate.com/products/mysql/mysql-comparison-tools/

● Solution may vary depending on the details of your project

Page 33: You're doing it wrong! Git it right!

Questions?

@corywebb @jlleblanc