Anzeige

.Git for WordPress Developers

13. Oct 2012
Anzeige

Más contenido relacionado

Anzeige

.Git for WordPress Developers

  1. .Git Wah? Everyting you wanted to know about .Git but were afraid to ask?
  2. Mike Van Winkle • Developer @ WP Engine • Freelance WordPress Developer for 3 years • Second career • Santa Rosa, CA
  3. Utopia • I write perfect code. • I upload perfect code to website. • Nobody touches my perfect code without asking me first. • Rinse and Repeat.
  4. Reality • Other developers on a project • I do stupid things • Clients sometimes think they can code • Shit happens
  5. Version Control • The Problem: How do we maintain stability and continuity in our websites/applications? • The Answer: We save versions.
  6. Realistic Workflow http://nvie.com/posts/a-successful-git-branching-model/
  7. Realistic Workflow http://nvie.com/posts/a-successful-git-branching-model/
  8. Version Control • As much about transitioning a website between states as it is recording changes. • Deployment is quicker and safer. • Changes can be easily “rolled” back. • A google example
  9. Subversion or .Git • SVN solves the problem by saving a “revision” with each change committed. Developers then can update code to a specific # • Git Solves the problem by tracking the differences between commits
  10. Subversion or .Git • .Git is a “distributed” model with less server overhead and better performance • .Git makes complex workflows much easier to manage • Github.com is a great community of projects and developers sharing code. • Little functions that make life easy (examples later)
  11. Getting Started:What you need • A command line tool like iTerm or Putty • RSA Key Pair: https://help.github.com/articles/generating-ssh-keys • Some Code
  12. Getting Started: Set up a repo
  13. Getting Started: Set up a repo
  14. Getting Started:Then What? $ git init [create a .gitignore file ... touch .gitignore ] $ git add . --all OR $ git add wp-content $ git add remote origin git@github.com:mikevanwinkle/My-WP-Site.git git commit -am “initial commit” git push origin master
  15. What to ignore? • Large Files • Local Files • custom .htaccess files • custom wp-config.php • WP Core • Folders containing .svn info • Historic Files
  16. What to ignore? *~ wp-content/upgrade/* .htaccess ? .svn wp-content/uploads wp-config.php ? .cvs wp-content/blogs.dir/*/* .git pclzip-* .listing log.txt *.bak debug.log *.swp gallery/* cache wp-content/gallery/* .cache wp-content/album/* temp wp-content/plugins/plugins tmp *.tmp imagecache* uploads* *_backup wp-config-sample.php wp-content/w3tc* wp-content/w3-*
  17. Deployment On your webhost, you’ll need ssh access or you will need a tool that can deploy via FTP ( Beanstalk ? ) $ git clone git@github.com:mikevanwinkle/My-WP- Site.git $ git pull origin master
  18. Development: Example [on your local] $ git branch dev $ git checkout dev [make some changes] $ git commit -am “Making my dev changes” $ git push origin dev [pushes the new branch up] [on production site] $ git pull origin dev $ git checkout dev
  19. Development: Example [on your local] $ git branch feature-1 $ git checkout feature-1 [make some changes] $ git commit -am “Making my dev changes” $ git push origin feature-1 [pushes the new branch up] $ git checkout master $ git merge feature-1 $ git commit -am “merge feature-1 with master” $ git push origin master
  20. Realistic Workflow
  21. Realistic Workflow
  22. Cool Stuff: Hooks • applypatch-msg • post-commit • post-update • pre-commit • update • commit-msg • post-receive • pre-applypatch • pre-rebase
  23. Cool Stuff: Stash • applypatch-msg • post-commit • post-update • pre-commit • update • commit-msg • post-receive • pre-applypatch • pre-rebase
  24. Cool Stuff: Stash $ git stash save “Temp 2” $ git stash list $ git stash apply <STASH ID> http://git-scm.com/book/en/Git-Tools-Stashing
  25. Cool Stuff: Reset $ git reset --hard HEAD
  26. Cool Stuff: Reset $ git reset --hard HEAD
  27. Cool Stuff: Archive $ git archive HEAD | gzip > /tmp/ website.tar.gz
  28. Resources http://rkulla.blogspot.com/2011/08/some-points-on-git-vs-subversion.html http://ryanflorence.com/deploying-websites-with-a-tiny-git-hook/ http://git.wpengine.com/faq/ https://help.github.com/ http://git-scm.com/docs/git-merge
Anzeige