Weitere ähnliche Inhalte Ähnlich wie Git Basics at Rails Underground (20) Kürzlich hochgeladen (20) Git Basics at Rails Underground1. GIT BASICS
Ariejan de Vroom – Kabisa ICT
http://kabisa.nl
http://ariejan.net
http://twitter.com/ariejan
2. WHAT THE GIT?!
“I'm an egotistical bastard, and I name all my projects after
myself. First Linux, now git.” – Linus Torvalds
5. SURVEY
• Who is NOT using version control?
• Subversion? Mercurial?
• Anything else?
6. WHY GIT?!
• Distributed Repositories
• Non-linear Development
• Very fast branching and merging
• Toolkit Design
• Scales
• Cryptographic authentication of history.
9. ~/gitbasics $ echo "Live long and prosper" > README
~/gitbasics $ git add README
~/gitbasics $ git commit -m "Added README"
[master (root-commit)]: created 8e60b09: "Added README"
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 README
10. WHAT JUST HAPPENED?
~/gitbasics $ git log
commit 8e60b09d3082e9473944075cc01b3b67bb97d5c3
Author: Ariejan de Vroom <ariejan@ariejan.net>
Date: Mon May 11 21:51:24 2009 +0200
Added README
11. HOW GIT WORKS
Working Directory
git add
Staging Area
git commit
Repository
12. WORKFLOW
• Hack! ( TextMate, vim, ... )
• Stage your changes ( git add )
• Review your changes ( git status | diff )
• Commit (locally) ( git commit )
• Repeat
14. SURVEY
• How many of you use branching?
• Do you work exclusively on trunk/master?
• NEVER work on trunk/master?
16. LET’S BRANCH!
~/gitbasics $ git checkout -b new_feature
Switched to a new branch "new_feature"
~/gitbasics $ git branch
master
* new_feature
~/gitbasics $ git checkout master
Switched to branch "master"
~/gitbasics $ git branch -d feature3
Deleted branch feature3
18. MERGING
c1 c2 c3 c4 c7 master
c5 c6 new_feature
20. REBASING
• Bring a branch up-to-date
• Rebasing is rewriting history!
• Don’t use rebasing on a branch you’re
sharing!
21. REBASING
c1 c2 c3 c4 master
new_feature c3’ c4’ c5 c6
24. PUSH
~/gitbasics $ git add origin git@github.com/ariejan/
gitbasics.git
~/gitbasics $ git push origin master
26. WORKFLOW
Working Directory
add
Staging Area
commit checkout merge
Repository
push fetch pull
Remote
27. TAGGING
• Mark a point in history
• Optionally sign it cryptographically with
GnuPG
29. TAGGING
~/gitbasics $ git tag -a -m "Tag v1.0" v1.0
Switched to branch "new_feature"
~/gitbasics $ git tag
v1.0
~/gitbasics $ git push --tags
30. USING TAGS
~/gitbasics $ git checkout -b fix_1.0 v1.0
Switched to branch "fix_1.0"
~/gitbasics $ git rebase v1.0
~/gitbasics $ git log v1.0..HEAD
33. BISECTING
v1.0 Good or Bad? HEAD
c1 c2 c3 c4 c5 c6 c7
34. BISECTING
Good or
v1.0 HEAD
Bad?
c1 c2 c3 c4 c5 c6 c7
~/gitbasics $ git bisect start
~/gitbasics $ git bisect bad
~/gitbasics $ git bisect good v1.0
~/gitbasics $ git bisect bad | good
~/gitbasics $ git bisect reset
~/gitbasics $ git bisect start HEAD v1.0
35. RELEASE
MANAGEMENT
• Manage your DTSP environments
• Branches to the rescue!
36. RELEASE
MANAGEMENT
~/gitbasics $ git branch production master
~/gitbasics $ git push origin production
~/gitbasics $ git checkout --track -b production origin/production
37. RELEASE
MANAGEMENT
~/gitbasics $ git checkout production
~/gitbasics $ git rebase master
~/gitbasics $ git push origin production
38. TAGGING RELEASES
~/gitbasics $ git checkout master
~/gitbasics $ git tag -a -m "Tag v1.0.3" v1.0.3
~/gitbasics $ git push --tags
~/gitbasics $ git checkout production
~/gitbasics $ git rebase v1.0.3
~/gitbasics $ git push origin production
40. THE STASH
~/gitbasics $ git status
# modified: README
~/gitbasics $ git stash
~/gitbasics $ git status
nothing to commit
# Hack, stage, review, commit, etc.
~/gitbasics $ git stash pop
~/gitbasics $ git status
# modified: README
45. PULL REQUESTS
~/imdb $ git add -f boscomonkey
git://github.com/boscomonkey/imdb.git
~/imdb $ git checkout -b boscomonkey/master
~/imdb $ git pull boscomonkey master
~/imdb $ git checkout master
~/imdb $ git merge boscomonkey/master
~/imdb $ git push
48. THANKS!
Slides will be posted to http://slideshare.net/ariejan
Contact me at ariejan@kabisa.nl
or follow me at http://twitter.com/ariejan