Adding Source Control to Your Life
-
Upload
mark-kelnar -
Category
Technology
-
view
2.855 -
download
0
Transcript of Adding Source Control to Your Life
Adding Source Control to your
Life
Mark Kelnar2013
Sunday, May 19, 13
Adding Source Control To Your Life
Who is this guy?
Mark KelnarWP Engine - lead developer@renderandserve github.com/markkelnar
Sunday, May 19, 13
HTMLJavaScriptCSSPHPJava, C/C++, PythonRuby on Rails, Perl, bashetc.
Adding Source Control To Your Life
Do you use any of these?
Sunday, May 19, 13
Adding Source Control To Your Life
Words worth rememberinginitclonecheckoutbranchfetchdiffcommitpullpushrevert
Sunday, May 19, 13
Coding without source control is like ...
Adding Source Control To Your Life
photographer Emily West (Courtney)
Sunday, May 19, 13
Pick a version control system
git, subversion (svn), cvs, mercurial, and many more
Adding Source Control To Your Life
Sunday, May 19, 13
What do I do with it?
Adding Source Control To Your Life
domain.comlaptop / dev
New header
Sidebar widget
Facebook feed importer
Work on different project/features, switch between them seamlessly, merge them together without missing anything
Sunday, May 19, 13
Adding github.com and staging branch
Adding Source Control To Your Life
laptop / dev
New header
Sidebar widget
Really cool facebook thingy
laptop / dev
github repopull requestsbranches
staging serverbranch testinggit pull
production serverbranchgit pull
pull/push
pull/push
pull
pull
Sunday, May 19, 13
Because you want to work with other smart people who can help.
Adding Source Control To Your Life
Sunday, May 19, 13
Create local repo
Adding Source Control To Your Life
Let’s talk about a simple example, local repo
http://git-scm.com/downloads
Sunday, May 19, 13
Create local repo
Adding Source Control To Your Life
Sunday, May 19, 13
Learn to branch
git checkout mastergit checkout -b some-new-feature<edit files>git statusgit diffgit commit -a -m ‘Edit theme for new cool feature’<another edit>git commit -a -m ‘Forgot the blue border’
Adding Source Control To Your Life
* Don’t commit it to production unless it’s ready to go live
Example:
Sunday, May 19, 13
Diff then Commit
Adding Source Control To Your Life
Sunday, May 19, 13
Merge branch back into main branch
Adding Source Control To Your Life
Sunday, May 19, 13
Adding Source Control To Your Life
Questions so far?
Sunday, May 19, 13
Push to remote using sshHere are two waysA) push to a bare repo on server then pull to another working non-bare repo Or B) push from local branch to a branch on non-bare repo then merge that branch into checked out / production branch.
B) Initial setupssh [email protected] /var/www/html/git init domain.com- at this point has no working branches, not even master. Only after initial push below
On local - one time, add remote server repogit branch laptop - create a local dev branchgit remote add theserver [email protected]:/var/www/html/domain.com/.gitgit remote show theservergit push theserver laptop
On server - one time, after initial push from local, set up working branchgit checkout laptopgit branch production
Adding Source Control To Your Life
Sunday, May 19, 13
Push to remote using sshB) Work flow after initial setup
On local - in dev branch ‘laptop’<edit files>git commit -am ‘changed code’git push theserver laptop
On server - when want changes to go live, merge the branch into working branchgit diff production laptop (show what is changing first)git merge laptop production (do the merge)
Adding Source Control To Your Life
Sunday, May 19, 13
Push to remote using ssh
How it get’s more complicated from there ...
add other humansadd testing environmentsadd staging environmentsadd customers with issues, darn those customers!fast iterations, push a lot, how to code review, test, etc
Adding Source Control To Your Life
Sunday, May 19, 13
Push local to github repo
github.com
Create account
Create repository
Adding Source Control To Your Life
Sunday, May 19, 13
Push local to github repo
github.com
Create account
Create repository
Adding Source Control To Your Life
Sunday, May 19, 13
Push local to github repo
Step 2ssh-keygen -r rsa -C "[email protected]"Add ssh key to github ssh keyshttps://help.github.com/articles/generating-ssh-keys
Step 3 - local devgit init domain.comcd domain.com<add files>git add .git commit -a -m 'Initial commit'
Adding Source Control To Your Life
Sunday, May 19, 13
Push local to github repoStep 4
git remote add github [email protected]:markkelnar/domain.com.gitgit remote show githubgit pull github mastergit push github master
Adding Source Control To Your Life
Example SSH repo locator
Sunday, May 19, 13
Pull from github repo
Step 5 (on the server, one time setup)
ssh-keygen -t rsa -C "[email protected]"cd /var/www/html/git init domain.comgit remote add github [email protected]:markkelnar/domain.com.gitgit remote show github
Step 6git pull github master
Adding Source Control To Your Life
Sunday, May 19, 13
Adding Source Control To Your Life
Questions so far?
Sunday, May 19, 13
*~
.svn
.cvs
.git
.listing
*.bak
*.swp
cache
.cache
temp
tmp
*.tmp
imagecache*
uploads*
*_backup
wp-config-sample.php
wp-content/w3tc*
wp-content/w3-*
wp-content/upgrade/*
wp-content/uploads
wp-content/blogs.dir/*/*
pclzip-*
log.txt
debug.log
gallery/*
wp-content/gallery/*
wp-content/album/*
wp-content/plugins/plugins
.htaccess ?
wp-config.php ?
Ignore some files
Adding Source Control To Your Life
Sunday, May 19, 13
Common Excuses (end...)
I heard it's hard.I’m a solo developer.I don't have money. I don't have time.
Adding Source Control To Your Life
Sunday, May 19, 13
If time for more time ...What about staging branches?
What about pull requests?
Adding Source Control To Your Life
featurebranches
stagingbranch production
branchbug fixes
pull request
pull request
Sunday, May 19, 13
Resources
Adding Source Control To Your Life
http://git-scm.com/downloads
https://help.github.com/articles/set-up-githttps://help.github.com/articles/generating-ssh-keys
http://code.google.com/p/tortoisegit/
Sunday, May 19, 13
Thanks!
Adding Source Control To Your Life
Sunday, May 19, 13