Adding Source Control to Your Life

3,492 views
3,331 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,492
On SlideShare
0
From Embeds
0
Number of Embeds
45
Actions
Shares
0
Downloads
15
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Adding Source Control to Your Life

  1. 1. Adding SourceControl to yourLifeMark Kelnar2013Sunday, May 19, 13
  2. 2. Adding Source Control To Your LifeWho is this guy?Mark KelnarWP Engine - lead developer@renderandservegithub.com/markkelnarSunday, May 19, 13
  3. 3. HTMLJavaScriptCSSPHPJava, C/C++, PythonRuby on Rails, Perl, bashetc.Adding Source Control To Your LifeDo you use any of these?Sunday, May 19, 13
  4. 4. Adding Source Control To Your LifeWords worth rememberinginitclonecheckoutbranchfetchdiffcommitpullpushrevertSunday, May 19, 13
  5. 5. Coding without source control is like ...Adding Source Control To Your Lifephotographer Emily West (Courtney)Sunday, May 19, 13
  6. 6. Pick a version control systemgit, subversion (svn), cvs, mercurial, and many moreAdding Source Control To Your LifeSunday, May 19, 13
  7. 7. What do I do with it?Adding Source Control To Your Lifedomain.comlaptop / devNew headerSidebar widgetFacebook feedimporterWork on different project/features,switch between them seamlessly,merge them together without missing anythingSunday, May 19, 13
  8. 8. Adding github.com and staging branchAdding Source Control To Your Lifelaptop / devNew headerSidebar widgetReally coolfacebook thingylaptop / devgithub repopull requestsbranchesstaging serverbranch testinggit pullproduction serverbranchgit pullpull/pushpull/pushpullpullSunday, May 19, 13
  9. 9. Because you want to workwith other smart peoplewho can help.Adding Source Control To Your LifeSunday, May 19, 13
  10. 10. Create local repoAdding Source Control To Your LifeLet’s talk about a simple example, local repohttp://git-scm.com/downloadsSunday, May 19, 13
  11. 11. Create local repoAdding Source Control To Your LifeSunday, May 19, 13
  12. 12. Learn to branchgit 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 liveExample:Sunday, May 19, 13
  13. 13. Diff then CommitAdding Source Control To Your LifeSunday, May 19, 13
  14. 14. Merge branch back into main branchAdding Source Control To Your LifeSunday, May 19, 13
  15. 15. Adding Source Control To Your LifeQuestions so far?Sunday, May 19, 13
  16. 16. Push to remote using sshHere are two waysA) push to a bare repo on server then pull to another working non-bare repoOr B) push from local branch to a branch on non-bare repo then merge that branch into checked out /production branch.B) Initial setupssh me@server.comcd /var/www/html/git init domain.com- at this point has no working branches, not even master. Only after initial push belowOn local - one time, add remote server repogit branch laptop - create a local dev branchgit remote add theserver me@server.com:/var/www/html/domain.com/.gitgit remote show theservergit push theserver laptopOn server - one time, after initial push from local, set up working branchgit checkout laptopgit branch productionAdding Source Control To Your LifeSunday, May 19, 13
  17. 17. Push to remote using sshB) Work flow after initial setupOn local - in dev branch ‘laptop’<edit files>git commit -am ‘changed code’git push theserver laptopOn 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 LifeSunday, May 19, 13
  18. 18. Push to remote using sshHow 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, etcAdding Source Control To Your LifeSunday, May 19, 13
  19. 19. Push local to github repogithub.comCreate accountCreate repositoryAdding Source Control To Your LifeSunday, May 19, 13
  20. 20. Push local to github repogithub.comCreate accountCreate repositoryAdding Source Control To Your LifeSunday, May 19, 13
  21. 21. Push local to github repoStep 2ssh-keygen -r rsa -C "email@domain.com"Add ssh key to github ssh keyshttps://help.github.com/articles/generating-ssh-keysStep 3 - local devgit init domain.comcd domain.com<add files>git add .git commit -a -m Initial commitAdding Source Control To Your LifeSunday, May 19, 13
  22. 22. Push local to github repoStep 4git remote add github git@github.com:markkelnar/domain.com.gitgit remote show githubgit pull github mastergit push github masterAdding Source Control To Your LifeExample SSH repo locatorSunday, May 19, 13
  23. 23. Pull from github repoStep 5 (on the server, one time setup)ssh-keygen -t rsa -C "email@domain.com"cd /var/www/html/git init domain.comgit remote add github git@github.com:markkelnar/domain.com.gitgit remote show githubStep 6git pull github masterAdding Source Control To Your LifeSunday, May 19, 13
  24. 24. Adding Source Control To Your LifeQuestions so far?Sunday, May 19, 13
  25. 25. *~.svn.cvs.git.listing*.bak*.swpcache.cachetemptmp*.tmpimagecache*uploads**_backupwp-config-sample.phpwp-content/w3tc*wp-content/w3-*wp-content/upgrade/*wp-content/uploadswp-content/blogs.dir/*/*pclzip-*log.txtdebug.loggallery/*wp-content/gallery/*wp-content/album/*wp-content/plugins/plugins.htaccess ?wp-config.php ?Ignore some filesAdding Source Control To Your LifeSunday, May 19, 13
  26. 26. Common Excuses (end...)I heard its hard.I’m a solo developer.I dont have money.I dont have time.Adding Source Control To Your LifeSunday, May 19, 13
  27. 27. If time for more time ...What about staging branches?What about pull requests?Adding Source Control To Your Lifefeaturebranchesstagingbranchproductionbranchbug fixespull requestpull requestSunday, May 19, 13
  28. 28. ResourcesAdding Source Control To Your Lifehttp://git-scm.com/downloadshttps://help.github.com/articles/set-up-githttps://help.github.com/articles/generating-ssh-keyshttp://code.google.com/p/tortoisegit/Sunday, May 19, 13
  29. 29. Thanks!Adding Source Control To Your LifeSunday, May 19, 13

×