FTP Commando to Git Hero
WordCamp DenverNovember 16, 2013
Organize Fort Collins WordPress meetup
3 plugins on the WordPress repository
Build themes and plugins
1. What is version control, and why use it?
2. How to use version control with WordPress
3. Adding deployment to your workflow
What is version control?
me, pre-version control
Dated Folders
Problem #1How do you access deleted code?
Problem #2How do you effectively collaborate?
Problem #3How do you know what change is in what
folder?
Really long, descriptive folder names
Version ControlProvides a history of changes made
to files in a project
Version ControlProvides a history of changes made
to files in a project
Repository
Repository
GitA popular vcs created in 2005 by Linus Torvalds, the creator of the Linux kernel
DistributedEveryone has their own copy of the project
Don’t need a network connection
No central repository
Serverrepo
Distributed Version Control System
Computer Arepo
Computer Brepo
That’s all great, but how do I use it?
Fort Collins Lambkins
Interacting with Git
Terminal
Remember keyboarding class?
git-scm.com/downloads
git init
git add <filename>
Staging
File 1 Repository
File 2
File 3
git commit -m “Initial commit”
Good Commit Messages
1. Add navigation to header
2. Remove slider from homepage
Bad Commit Messages
1. Fixed that thing that was broken.
2. Edited some code. Now I need a beer.
You are now using version control!
QuickTime™ and aGIF decompressor
are needed to see this picture.
git log
git status
git commit -a -m “Commit Message”
git log
git status
git add .git commit -m “Add stylesheet”
How often should I commit?
Is there a good commit message I could
write?
Using Version Controlwith WordPress
+
1. Install a fresh copy of WordPress
2. Initialize a new git repository
3. Create a .gitignore file
4. Add the current files to staging
5. Commit those files to the repository as the first commit
1. Install a fresh copy of WordPress
2. Initialize a new git repository
git init
3. Create a .gitignore file
4. Add current files to staging
git add .
5. Commit staged files to the repository
git commit -m “Initial commit”
+
!
1. Make changes to files.
2. Add those changed files to staging.
3. Commit staged files to the repository.
4. Repeat.
Real World Examples
Scenario #1
The Client Changes Their
Mind
Check the project’s commit history
git log
Go back in time
git checkout <commit identifier>
Scenario #2
Collaborate with Another Developer
Remote Hosting Options
Setup Connection to Remote Repository
git remote add origin <path_for_remote>
Serverrepo
Computer Arepo
Send Repository to Remote Server
git push origin master
Serverrepo
Computer Arepo
Serverrepo
Computer Arepo
Computer Brepo
Developer Copies Repository Locally
git clone <url>
Serverrepo
Computer Arepo
Computer Brepo
Developer Connects to Repository
git remote add origin <path_for_remote>
Serverrepo
Computer Arepo
Computer Brepo
Developer Pushes Up Their Changes
git push origin <branch>
View Commit History
Branches
master
branch branch
Why?Stay more organized
Easily maintain your “in-progress” work separate fromyour completed, tested, and stable code
Collaborate with others more effectively
Build features in branches
master
branch bug fix
mergefeature
Only commit finished work to the master branch
Create branches for features and large bug fixes
Delete feature branches once merged
Tips
git branch <branch_name>git checkout <branch_name>
Create New Branch
master
branch
Build Cool Feature
master
branch
git checkout mastergit merge <branch_name>
Merge Completed Feature
Merge Completed Feature
master
branch
Keep Your Repository Clean
git branch -d <branch_name>
master
Deployment
Push code. Deploy in one click.
Setup Repository
Set Permissions
Create Remote Repository
Create Your Remote
git remote add beanstalk <url>
git push beanstalk master
Send Files to Your Remote
Create Deployment Environment
Add Server to Environment
Test Connection Settings
Deploy!
Resources
Beanstalk Guides -
http://guides.beanstalkapp.com
Git Book - http://git-scm.com/book
Git Immersion - http://gitimmersion.com/
Git Basics - http://teamtreehouse.com/library/git-
basics
Questions?
@greenhornet79
endocreative.com