Home
Introduction to Git for Drupal
Contents
1. add Instead of staging just roll back to earlier commits if ne You really don t need to stage most changes When to stage changes e Single complex bug You re feeling your way through bug resolution t Make a final all or nothing commit for the entire bug Seeing diffs visually If running X Windows use tkdiff kompare etc If terminal based try vimdiff Try to get a good set of colors for vimdiff e http luhman org blog 2009 08 25 git difftool and vimdiff sums S git difftool merge tool candidates tkdiff kompare vimdiff Viewing sums php Hit return to launch tkdiff dothisfor each file n EN NH TkDiff 4 1 4 File Edit View Mark Merge EE KEEKSID i Bh ree S Biss 212 2 S BI v ftmp diff N tr70 ENNE unnn D C KI 5555 Lex ve Ve ENNE t PONE on onn omnem ENNE Bisect your bugs away Find the commit which has 4 4 9 sums git bisect start sums BISECTING git bisect bad mark current commit as bad sums BISECTING git bisect good NULL mark initial tag as good Bisecting 2 revisions left to test after this roughly 1 steps fe76bdc9 4095acb0b24f c6424640439e04e2abe Append to sums php fe76bdc BISECTING grep 9 sums php didn t see 9 so good commit fe76bdc BISECTING git bisect good fe76bdc9 only need fii Bisecting 1 revisions left to test after this roughly 1 step b9661c
2. SHAL ID 583266 38d5483b49F27c077469bcd7d000830d4 Ros 1 Find next prev commit containing zc All fields 4d earch 1 Patch Tree Diff v Old version w Neu version c Comments Author Your name here lt you yourdoma DCommitterz Your name here lt youyourd Parent 1cf32a9b2a 9deddfb26a7eeeb21 Parent 76fe251be4964ab29bed4ec6baba Branch master Follows NULL Precedes Merge branch prods N Fixing bugs or adding features with topic Think New bug means new temporary branc Even if fix belongs to a branch may need to work in merged master Drupal becomes inoperable if you switch to drupal contrib with no settings php master git checkout b masterAddSums create new temp branch from master Switched to a new branch masterAddSums masterAddSums echo print 6 6 12 n gt gt sums php feature masterAddSums git commit a m Add 6 6 12 on sums php masterAddSums ee3dc8f Add 6 6 12 on sums php 1 files changed 1 insertions 0 deletions masterAddSums git diff stat masterAddSums master sums php 1 1 files changed 0 insertions 1 deletions MN masterAddSums git log pretty oneline 1 find commit we added ee3dc8fba9e931a9678654602fc44617bdd6a771 Add 6 6 12 on sums php masterAddSums git checkout master Switched to branch master master git merge masterAddSums Updating 58326e3 ee3dc8f NER files changed 1
3. insemg ster git branch d eted branch masterAd merge change into master TE temp bra a longer n Cherry pick last commit from master bac Ensure sums branch reflects all changes in master This has costs amp benefits Cost of keeping branches up to date Benefits of having a complete set of changes master git checkout sums switch to sums branch Switched to branch sums sums tail 1 sums php confirm sums php lacks new line print 5 5 10 in s sums git cherry pick ee3dc8fba9e93 apply commit from master only n Finished one cherry pick i i sums 74af8cd Add 6 6 12 on sums php 1 files changed 1 insertions 0 deletions sums tail 1 sums php orint 6 6 12 An confirm commit applied master Git s stash feature allows context switching Your boss wants you to work on a different branch Stash current branch changes switch then re apply prods echo print 4 4 16 n gt gt prods php you re working on prods master git status On branch prods modified prods php no changes added to commit use git add and or git commit a master git checkout sums boss wants work on sums error You have local changes to prods php cannot switch branches master git stash stas Saved working directory and index state WIP on master d2adc75 Add HEAD is now at d2adc75 Add 6 6 12
4. on sums php To restore them type git stash apply master git checkout sums work on sums branch Switched to branch sums sums git status no changes on sums branch On branch sums nothing to commit working directory clean sums git checkout prods IL itched to branch prods T ds git stash apply n branch prods modified prods phy ages added to commit 1 go back to prods branch Let s move this to our prod server Problem How to move to prod server when ev server is behind a NATed firewall Solution Copy Git repository to prod and clone back to dev tar zcf gitDemo tar gz gitDemo tar up existing repo scp gitDemo tar gz me iprod com home me untar on prod com mv gitDemo gitDemoOrig don t clone over our original git clone ssh me prod com home me gitDemo Initialized empty Git repository in home me gitDemo git me prod com s password j remote Counting objects 23 done remote Compressing objects 100 20 20 done remote Total 23 delta 5 reu 3 O delta 0 Receiving objects 100 23 23 Resolving deltas 100 5 5 done one Let s see what we cloned back from p master git remote v verbose list of remote repos origin ssh me prod com home me gitDemo master git branch va verbose list of all branches master 58326e3 Merge branch prods remotes origin HEAD origin master remotes
5. origin master 58326e3 Merge branch prods remotes origin null cfdc52d Initial commit remotes origin prods 76fe251 Add prods php file remotes origin sums 1cf32a9 Add 545 10 master This brings up a whole discussion of handling remote branches and pushing to remote repositories http luhman org blog 2009 07 28 gitep sh how A touch of advanced topics Pre commit hooks Never commit code with syntax errors e http luuhman org blog 2010 02 12 cheap php lint checking git The best way to handle merge conflicts Avoid them Push and pull often Continuous integration with Hudson Test builds with every Git commit e http luhman org blog 2009 12 16 installin g hudson phing phpunit and git ubuntu NetBeans or other IDE integration CVS or SVN integration Migrating Drupal to Git Phase 1 Read only Git mirror of Drupal and contrib Phase 2 Drupal managed by patches with Git Limited or no branches Limited or no push pull fetch Phase 3 Fully embrace power of Git http drupal org community initiatives git http docs google com present view id dp6bhf4_6gfv8fSfq Cloning Drupal 7 git clone git github com drupal drupal git Initialized empty Git repository in root tmp gitD7 drupal git Receiving objects 100 106674 106674 21 37 MiB 155 KiB s done Resolving deltas 100 79194 79194 done cd drupal CVS git branch va CVS 386560b P
6. submodules k http progit org book ch6 7 html Questions and Thank you David Luhman Iuhman org linkedin com in davidluhman
7. Introduction to Git for Drupal David Luhman Iuhman org linkedin com in davidluhman A bit about your humble presenter Born and raised in Colorado Spell Ada gt Johnson Space Center Spell FORTRAN gt Five years in Japan Back to CU Boulder for MBA Spell AE c Silicon Valley Spell Git gt Here today From Drupal 4 6 but Drupal is not my day job amp M Why Revision Control mm e The need to track similar but different versions First test in The J oel Test http en wikipedia org wiki The_Joel_Test Life is too short to waste time with folks who won t use revision control A short history of version control SCCS 1972 and RCS 1982 RCS ubiquitous simple but locking amp scale issues RCS scripting CVS uo Solves locking and scale issues but adds complexity Rational ClearCase multi site 199 Distributed revision control systems d BitKeeper Used by Linus Torvalds for Linux 1999 f Git Workflow from BitKeeper Opposite of CVS 200s Monotone Darcs Mercurial Bazaar Installing Git Make sure to install Git version 1 5 or higher Versions 1 4 x and lower have legacy commands Version 1 6 6 and higher have smart HTTP transport Current version 1 7 2 from http git scm com Ubuntu apt get install git core Suggested packages git doc git cvs git svn g
8. atch 295990 by mr ba remotes origin CVS 386560b Patch 295990 by mr bail remotes origin DRUPAL 3 0 5e5375d removed errors on empty remotes origin DRUPAL 3 00 469e0dc Renamed the SQL upgrade remotes origin DRUPAL 4 0 7244fbe Made sure session cache remotes origin DRUPAL 4 7 86c491c push version r remotes origin DRUPAL 5 bf60f36 Bump version number 11 remotes origin DRUPAL 6 69b185e Now onto Drupal 6 18 a remotes origin HEAD gt origih CVs remotes origin drop e9588cb Imported sources CVS t Pulling down fresh updates for Drupal master git remote v origin git github com drupal drupal git master git pull origin CVS From git github com drupal drupal branch CVS gt FETCH HEAD Removing modules overlay images loading gif Merge made by recursive CHANGELOG txt includes bootstrap inc includes common inc includes database mysql schema inc includes database pgsql database inc Site builders Handling contrib modu Work in progress for me but seems like three choices Choice 1 Download and manage tarballs e Simple but loses Git tracking of mods to repositories on drupa e http drupal org node 803746 Choice 2 Manage with Git s submodule feature Probably best tracking but submodules can be tricky i 1 f http progit org book ch6 6 html Choice 3 Manage with Git s subtree merge method e Still tricky but possibly easier th an
9. b236c246d8ee90477857d7e468c330140c Append mistaken 4 4 b9661cb BISECTING git bisect bad b9661cb Bisecting 0 revisions left to test after this roughly 0 ste b89a9c901db024cca1979550cf8c2db23bd8629a Append more to sum b89a9c9 BISECTING grep 9 sums php b89a9c9 BISECTING git bisect good b89a9c9 b9661cb236c246d8ee904778b7d7e468c330140c is first bad commit commit b9661cb236c246d8ee904778b7d7e468c330140c Author Your name here lt you yourdomain example com gt Date Mon Jun 21 00 22 16 2010 E uw Append mistaken 4 4 9 100644 100644 28a07a97 301c44eofle M sums php b89a9c9 BISECTING git bi set done with bis Previous HEAD position was b89a9c9 ERend more to sums Switched to branch sums sums s Let s add another branch for prods sums git checkout null start from empty commit Switched to branch null null git checkout b prods create new branch named prods Switched to a new branch prods prods cat prods php php print 1 1 1 Mn print 2 2 4 Nn print 3 3 9 Nn prods git add prods php need to stage new files prods git commit m Add prods php file prods 3ef9948 Add prods php file F n 1 files changed 4 insertions 0 deletions i create mode 100644 prods php prods ls a git gitignore prodsgphp prods 1 What happen Git switches fil
10. bled 000 default etc apache2 ls FA1 git branches COMMIT EDITMSG config description HEAD hooks index info logs bjects Qi ec simple repository with multiple branch Git s killer feature Fast easy compact intra repository branches Think how you might do similar with Drupal drupal core branch drupal contrib branch your custom code branch e master branch that merges everything together http drupal org node 803746 http books taglconsulting com scalability dr hilis a Our example Simple calculator Branch for code from addition expert branch sums e Branch for code from multiplication expert branch prods Setup repository and create null branc mkdir gitDemo S ed _ git init Initialized empty Git repository in home me gitDemo git master 4 touch gitignore note branch master from master 4 git add master 4 git commit m Initial commit mpletion sh master root commit 4b14ca0 Initial commit O files changed 0 insertions 0 deletions create mode 100644 gitignore master git tag NULL create tag NULL A master git branch va list all branches 1 masti M A AA master 4bl4ca0 Initial commit for empty repository master git branch m master null rename mas bran a E null git branch v i EN kial null 4b14ca0 I empty eposi bv 3 Cr
11. e system under you when s branches Let s see both branches by merging together prods git checkout null start from empty commit Switched to branch null null git checkout b master create new branch master Switched to a new branch master master git merge sums merge in the sums branch Updating etdo52d lcf32a9 Fast forward sums php 6 1 files changed 6 insertions 0 deletions create mode 100644 sums php master git merge prods merge in the prods branch F Merge made by recursive prods php 4 1 files changed 4 insertions i O deletions create mode 100644 prods php ls a Slt gartig master ow we have all files php ods ma iter Let s see our branches master git branch va verbose view of all branches master 58326e3 Merge branch prods null cfdc52d Initial commit prods 76fe251 Add prods php file PEE MS Help anne qoti2as Add 5as5eqo Merge branch prods Your name H 2010 06 22 22 54 50 Add prods php file Your name t 2010 06 22 22 52 03 A Add 5 5 10 Your name H 2010 06 22 22 50 08 master 5 gitk amp start GUI tool Append mistaken 4 4 9 Your name H 2010 06 22 22 48 53 fippend more to sums php Your name H 2010 06 22 22 45 48 master Append to sums php Your name t 2010 06 22 22 45 25 Add sums ph Your name H 2010 05 22 22 45 39 Initial commit Your name H 2010 06 22 22 43 31
12. eate branch sums null git checkout b sums Switched to a new branch sums sums cat sums php php print 1 1 2 Nn sums git status find out what needs adding committing On branch sums Untracked files use git add lt file gt to include in what will be committed sums php nothing added to commit but untracked files present use git sums git add sums php need to add new files to track sums git commit m Add sums php note indicating staged added before commit sums 85 3934 Add sums php 1 files changed 2 insertions 0 deletions T create mode 100644 sums php gt sums ost in prompt i othing staged after commit Append to sums php sums echo print 2 2 4 n gt gt sums php sums git status On branch sums Changed but not updated use git add lt file gt to update what will be committed use git checkout lt file gt to discard changes in or note how to rollback change checkout sum modified sums php no changes added to commit use git add and or git commit sums git add sums php stage changes by adding sums git commit m Append to sums php prompt tells us have staged changes sums fe76bdc Append to sums php fe76bdc is SHA 1 commit hash 1 files changed 1 insertions 0 deletions sums echo prin
13. git a sums php b sums php index 8821e12 dfabbe4 100644 a sums php b sums php GA 6 6 GG print 4 4 9 Xn print 4 4 9 Xn print 5 5 10 n sums git diff staged U0 diff git a sums php b sums php index 301c44e 8821e12 100644 a sums php b sums php 5 0 6 GA print 4 4 9 An print 4 4 9 An sums git diff HEAD UO diff git a sums php b sums php index 301c44e dfabbe4 100644 a sums php b sums php 8 5 0 6 print 4 4 ment 5 5 10 An oar gt Push Git Gui gitDemo home daddy gitDemo Repository Edit Branch Commit Merge Remote Tools Help Current Branch sums D junk txt 4 oh php sums php print 1 1 2 An print 2 2 4 n print 3 3 B Sn print 4 4 9 n print 4 4 9 n print 5 5 10 An dl RILL 4 SSS P m k taged Changes Will Commit Yj sums php 4 Commit Message sw Cc w Amend Last Commit The following line is staged print 4 4 9 sn It has been replaced with the unstaged print 5 5 10 n Rescan Stage Changed Sign OFF Commit So sums php has both staged and unstaged changes Ready Recommendations on staging Commit directly and frequently when things When adding new code When making simple bug fixes e git commit a m My commit message a means
14. it gui gitk Making from source is straight forward http Iuhman org blog 2009 06 1 1 building git ubuntu Mac http code google com p git osx installer Windows http code google com p msysgit Git Bash and standard Tk GUI Don t worry about Preview or B Select Git Bash only t and git gui wording works great forgo ii with regular comman Customize Git configuration on Linu Edit gitconfig user name Your Name Comes Here email you yourdomain example com difftool difftool vimdiff http www kernel org pub software scm git docs user manual html telling git your Add to bashrc alias gbv git branch v alias gbva git branch va alias gs git status Git completion stuff 2010 05 16 source git completion sh ub f git completion sh can show dirty unstaged and staged GIT PS1 SHOWDIRTYSTATE true git psl from git completior PS1 h myPWD __git_psl1 appends branch name to bs t x luhman org blog 2009 0 1y git sample first repository etc apache etc apache2 git init Initialized empty Git repository in etc apache2 git etc apache2 git add etc apache2 git commit m Initial commit master root commit da3d4d3 Initial commit of etc apache2 directory 119 files changed 2196 insertions 0 deletions create mode 120000 sites ena
15. t 3 3 6 n gt gt sums php sums git commit a m Append more to sums php co sums b89a9c9 Append more to sums ph note new t files changed 1 inseftio em al ms Staged versus unstaged changes sums echo print 4 4 9 n gt gt sums php we ll fix error later sums cat gt junk txt We won t stage this file just want to see unstaged in Git GUI sums git add sums php stage change to sums php sums git status On branch sums Changed but not updated use git add lt file gt to update what will be committed use git checkout lt file gt to discard changes in working directory modified sums php Untracked files E use git add lt file gt to include in what will be committed junk txt dk dk db db c Mino changes added to commit use git add and or git commit a sums Staged versus unstaged via Git GUI sums git gui amp we ll commit change to sums php thru GUI Git Gui gitDemo home daddy gitDemo Repository Edit Branch Commit Merge Remote Tools Current Branch sums BE 1 4 1 5 BE lt php print 1 1 2 n E 2 2 A a Dr Message w Amend Last EN Rescan Stage Changed Changed Sign oFF Sign oFF Commit Staging can lead to some diff oddities sums git diff UO diff
Download Pdf Manuals
Related Search
Related Contents
取扱説明書 - マックスレイ Documentation technique Smeg F610 Instructions for Use Atención 取扱説明書一覧 - M VisuLize-FVIII ELISA kit - quantitative determination of Factor VIII BIJSLUITER ATROVENT HFA 20 MCG/VERSTUIVING NEC N8406-026 Handbook Copyright © All rights reserved.
Failed to retrieve file