More Related Content Similar to Git Basics Philips (20) Git Basics Philips2. 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?
• 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
20. REBASING
• Bring a branch up-to-date
• Rebasing is rewriting history!
• Don’t use rebasing on a branch you’re
sharing!
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
31. 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
33. CONFLICTS
~/gitbasics $ git merge awesome_feature
Auto-merged README
CONFLICT (content): Merge conflict in README
Automatic merge failed; fix conflicts and
then commit the result.
~/gitbasics $ vim README
~/gitbasics $ git add README
~/gitbasics $ git commit -m “fixed merge
conflict”
35. ASSUME THIS
~/gitbasics $ svn log http://svnhub.com/project/trunk
------------------------------------------------------
r17048 | ariejan | 2009-06-30 ....
Updated README.
SVN Repository courtesy of SVNHub.com
36. CHECKOUT
~ $ mkdir gitbasics
~ $ cd gitbasics
~/gitbasics $ git-svn init http://svnhub.com/project/
trunk
~/gitbasics $ git-svn fetch -r17048
A README
39. WORKFLOW
~/gitbasics $ git-svn init URL
~/gitbasics $ git-svn rebase && git-svn fetch
~/gitbasics $ git checkout -b new_feature
~/gitbasics $ git add && git commit
~/gitbasics $ git checkout master
~/gitbasics $ git-svn rebase
~/gitbasics $ git merge new_feature
~/gitbasics $ git-svn dcommit
40. SURVEY
• Who is going to try Git?
• Stick with SubVersion?
• Try git-svn?