T3dd10 git
Upcoming SlideShare
Loading in...5
×
 

T3dd10 git

on

  • 2,890 views

 

Statistics

Views

Total Views
2,890
Views on SlideShare
2,889
Embed Views
1

Actions

Likes
0
Downloads
25
Comments
0

1 Embed 1

http://krautsock.posterous.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

T3dd10 git Presentation Transcript

  • 1. GIT-Workshop Using GIT (distributed version control) for TYPO3- Development TYPO3 Developer Days 2010 Elmshorn Peter Niederlag T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 2. Agenda Introduction Version Control GIT vs. svn Installation Create a repository Basic wording and concepts File exclusion (.gitignore) Branching Merging Resolving Conflicts Collaboration, going remote Stashing Rebasing SVN interoperability Links T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 3. Version Control Teamwork in running project What was changed by whom, why and when? Version Control System (VCS) cvs (Concurrent version System), svn (subversion) Central, non distributed, one history, no easy local commit or history possible Distributed Version Control System (DVCS) Multiple, non-central repositories with their own full history Easy colaboration between repositories git, bazaar, mercurial, darcs, .... T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 4. GIT vs. svn Pro Distributed Leightweight branches Efficiency (fast history, disk space) rebasing Con Something new to learn Improper usage(rebasing/reset) can cause trouble T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 5. Installation Distro packages: Debian based: git-core(git), gitk, (gitweb) Fedora: git, gitk, (git-email), (gitweb), git-all (git-arch git-cvs git-email git-gui gitk git-svn perl-Git) OpenSuse: git/git-core Gentoo: dev-util/git (includes gitk and gitweb) Windows: http://code.google.com/p/msysgit/ git --help T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 6. Most Important Commands git init git config git add git clone git commit git remote git log git fetch git branch git pull git checkout git push git status git merge git reset git rebase git tag git diff git mv git blame git rm gitk T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 7. Configure git Setup e-mail and name $$ git config --global user.name "Your Name Comes Here" git config --global user.name "Your Name Comes Here" $$ git config --global user.email you@yourdomain.example.com git config --global user.email you@yourdomain.example.com Color it up $$ git config --global color.ui auto git config --global color.ui auto $$ # git config --global color.diff auto # git config --global color.diff auto $$ # git config --global color.status auto # git config --global color.status auto $$ # git config --global color.branch auto # git config --global color.branch auto $$ git config --global pager.status yes git config --global pager.status yes T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 8. Create a repository $$ mkdir myproject mkdir myproject Create a repository $$ cd myproject cd myproject (very fast) $$ git init git init $$ ## ... hack on files ... hack on files $$ git add . git add . Add files $$ git commit git commit $$ git log git log Commit Check the log T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 9. Basic wording and concepts Repository holds all versioning information and data (.git or GIT_DIR) Working tree is where the working files are, a „bare“ repository does not have a working tree The Index the glue between the working tree and the repository, sometimes also referred to as the „staging area“. Changes that are to be performed with next commit T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 10. SHA-1 Hashes Git doesn't have numeric version id's like subversion or bazaar Each object (commit, tree, blob, tag) has a unique SHA-1, which is calulated from the content by git SHA-1 can be abbreviated (at least four signs) References are used for more meaningful names for any SHA-1 of a commit Tags: refs/tags Branches: refs/heads Remotes: refs/remotes T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 11. More Work $$ git status git status Doing some more $$ # hack, hack # hack, hack work on the $$ git status git status $$ git add git add working tree $$ git status git status $$ git commit -m 'my commit message' git commit -m 'my commit message' $$ git log git log $$ git status git status T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 12. File exclusion (.gitignore) Ignoring/Excluding files .git/info/exclude (repository) .gitignore (working tree, anywhere) Reversing Exclusion Can be done by „!“ prefix !index.html T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 13. Branching ## create branch create branch Create a Branch $$ git branch myfeature git branch myfeature ## checkout branch checkout branch Checkout a Branch $$ git checkout myfeature git checkout myfeature ## shortcut, create and checkout shortcut, create and checkout List Branches $$ git checkout -b myfeature git checkout -b myfeature Delete Branch ## list available branches list available branches $$ git branch -av git branch -av Rename a Branch ## delete branch delete branch $$ git branch -d obsoletebranch git branch -d obsoletebranch ## rename a branch rename a branch $$ git branch -m oldname newname git branch -m oldname newname T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 14. .git/config .git/config Holds configuration for the repository Setup of branches and remotes Default setup for merging of branches T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 15. Work on any branch $$ git branch git branch Doing some more $$ git checkout whatever git checkout whatever work on any $$ # hack, hack # hack, hack $$ git status git status branch (git branch, $$ git add git add $$ git status git status git checkout, git $$ git commit -m 'my commit message' git commit -m 'my commit message' $$ git log git log commit) $$ git status git status $$ git branch git branch $$ git checkout whatever git checkout whatever T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 16. Merging ## merge another branch merge another branch Merging $$ git merge otherbranch git merge otherbranch Fast Forward ## merge, withoud committing merge, withoud committing $$ git merge –no-commit otherbranch git merge –no-commit otherbranch fast-forward is a special case of a ## merge, but combine all commits into one merge, but combine all commits into one $$ git merge –squash otherbranch git merge –squash otherbranch merge, where only the other branch has additional commits and our branch can just be „moved forward“ T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 17. Resolving Conflicts Conflict ## merge another branch merge another branch $$ git merge otherbranch git merge otherbranch when ... CONFLICT (content): Merge conflict in foobar ... CONFLICT (content): Merge conflict in foobar Automatic merge failed; fix conflicts and then commit the result Automatic merge failed; fix conflicts and then commit the result merging $$ git status git status ... ... ## both modified: foobar both modified: foobar ..... ..... $$ git diff; git diff –ours; git diff –theirs git diff; git diff –ours; git diff –theirs ## resolve resolve $$ „edit file to solve the conflict“ „edit file to solve the conflict“ $$ git add foobar git add foobar $$ git commit git commit ## alternativ: alternativ: $$ git mergetool git mergetool T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 18. Collaboration, going remote remotes ## remotes remotes $$ git remote git remote Adding other $$ git remote add myname URL git remote add myname URL repositories for cowork $$ cat .git/config cat .git/config By default remote is $$ git remote add pn git remote add pn called „origin“ http://h01.niekom.de/sandbox.git http://h01.niekom.de/sandbox.git git clone is shortcut Create rep Add remote Add local branch that tracks remote branch T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 19. Remotes: fetch, pull, push git fetch Fetches any remote commits git pull Fetches any remote commits and merges them, boils down to git fetch plus git merge git push Pushes any „new“ local commits to the Remote T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 20. Change latest commit ## change the most recent commit change the most recent commit ATTENTION $$ git commit --amend git commit --amend only use if the ## hack, add, remove files to the index hack, add, remove files to the index commit was not ## change the most recent commit change the most recent commit published yet! $$ git commit --amend git commit --amend T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 21. Adding interactiv ## interactive adding interactive adding Very useful to $$ git add -i git add -i split/rearrange $$ git add -p git add -p the changes into commits T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 22. Stashing ## the stash the stash The stash, an $$ git stash git stash additional space $$ git stash save -m 'some temp patch' git stash save -m 'some temp patch' $$ git stash pop git stash pop to keep patches $$ git stash apply git stash apply T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 23. Rebasing A series of commits can easily be rewritten by git rebase Usefull to maintain some local patches/commits on top of another/upstream branch NEVER rebase anything that has been published already! T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 24. Rebase, example ## rebasing the latest two commits rebasing the latest two commits $$ git rebase -i HEAD~2 git rebase -i HEAD~2 pick c34fd56 dreinmal xx pick c34fd56 dreinmal ## Rebase f5614bf..c34fd56 onto f5614bf Rebase f5614bf..c34fd56 onto f5614bf ## ## Commands: Commands: ## p, pick == use commit p, pick use commit ## r,r, reword = use commit, but edit the commit message reword = use commit, but edit the commit message ## e, edit == use commit, but stop for amending e, edit use commit, but stop for amending ## s,s, squash = use commit, but meld into previous commit squash = use commit, but meld into previous commit ## f,f, fixup = like "squash", but discard this commit's log message fixup = like "squash", but discard this commit's log message ## ## If you remove a line here THAT COMMIT WILL BE LOST. If you remove a line here THAT COMMIT WILL BE LOST. ## However, if you remove everything, the rebase will be aborted. However, if you remove everything, the rebase will be aborted. T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 25. SVN interoperability git svn Plugin to work on SVN repositories Basic commands git svn clone [–trunk URL –tags URL --branches URL] URL git svn fetch git svn rebase Git svn dcommit Can be done for a bare repository T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 26. TYPO3 Git Mirror Clean svn mirror $$ git clone http://github.com/typo3/typo3v4core.git git clone http://github.com/typo3/typo3v4core.git Updated every 5 minutes Use, fork, push share ;) Some (historic) branches filtered Unofficial http://wiki.github.com /typo3/typo3v4core/ T3DD10 Elmshorn, Peter Niederlag, niekom netservice
  • 27. Links „unofficial“ TYPO3 Git Mirror http://github.com/typo3/typo3v4core Videos http://gitcasts.com/ Git – SVN Crash Course http://git.or.cz/course/svn.html Git Community Book http://book.git-scm.com/ Pro Git (Book) http://progit.org/book/ Git verstehen und nutzen http://chemnitzer.linux-tage.de/2009/vortraege/detail.html?idx=10 Git is MacGyver, Managing Kernel sources with Git http://chemnitzer.linux-tage.de/2010/vortraege/detail.html?idx=469 T3DD10 Elmshorn, Peter Niederlag, niekom netservice