git
git
get git on board
git?


• Version control system
git?


• Version control system
• Designed and developed by Linus Torvalds
  for Linux kernel development
git?

• Version control system
• Designed and developed by Linus Torvalds
  for Linux kernel development
• Like Subversion...
git?

• Version control system
• Designed and developed by Linus Torvalds
  for Linux kernel development
• Like Subversion...
git > svn
git > svn
git > svn

• Distributed
 • Every git repository is self-contained and
    includes a complete history of commits.
    (i....
git > svn

• Distributed
 • Every git repository is self-contained and
    includes a complete history of commits.
    (i....
git > svn
• Distributed
 • Every git repository is self-contained and
    includes a complete history of commits.
    (i.e...
git > svn
• Distributed
 • Every git repository is self-contained and
    includes a complete history of commits.
    (i.e...
git > svn


• Lightweight Branching
 • Branch and merge often (per feature?)
git > svn

• Lightweight Branching
 • Branch and merge often (per feature?)
 • Intelligent 3-way merging = rarely manual
git > svn

• Lightweight Branching
 • Branch and merge often (per feature?)
 • Intelligent 3-way merging = rarely manual
git > svn


• Small Space Requirements
 • Ex: Mozilla: SVN:12GB => git:420MB
git > svn


• git submodules vs svn externals
 • Not covered in this presentation
A couple new concepts

• “Remote” or “upstream”: A remotely
  accessible repository.
 • Push to a remote
 • Pull from a re...
A couple new concepts
• “Staging area” or “index”: What will go into
  your next commit.
  • Example:
    • mate new_file.r...
Everything clear?
Get Started
Get Git Started
Get Git Started


• Yes, I know it’s getting gitting old
Get Git Started

•   Install on OSX

    •   git-osx-installer - Recommended.

    •   OR

    •   sudo port install git-c...
Get Git Started

• Configure your user
 • git config --global user.name "Bobby SV"
 • git config --global user.email
    "bob...
git commands: basics
  git init                           Initialize a git repository.

 git add                          ...
git commands: branches
 git tag -a name                      Add a tag with the indicated name.

     git tag -l          ...
git commands: remote
        git clone url          Clone a repository. Sets up master branch w/ origin remote.


        ...
git commands: advanced
git checkout --track -b branch origin/
                                            Create a corresp...
overwhelmed?
git workflowz
Flow #1: simple/local
• cd project_cornice
• git init
• Set up your ignores (next slide)
• git add .
• git commit -a -m "I...
Flow #1: simple/local
• More on .gitignore files
 • Like SVN’s `svn propset ignore`
 • For example, in project root,
    ad...
Flow #2: local with
            branches
(master)$ git branch test_branch
(master)$ git checkout test_branch
Switched to b...
Flow #3: remotes

•   git clone git@github.com:rangsikitpho/cornice.git

•   cd cornice

•   mate new_file.rb

•   git add ...
Flow #4: full cycle
 •   git clone git@github.com:rangsikitpho/cornice.git

 •   cd cornice

 •   git checkout -b feature_...
Flow #4: full cycle
            •   git clone git@github.com:rangsikitpho/cornice.git

            •   cd cornice

       ...
Bonus!!!
•   Have dropbox? (http://dropbox.com)
    •   Use it as a remote!
•   How?
    •   Main computer, from existing ...
Refs
•   git-osx-installer:

    •    http://code.google.com/p/git-osx-installer/

•   git branch info on command prompt

...
Git  Tech Talk
Git  Tech Talk
Git  Tech Talk
Upcoming SlideShare
Loading in …5
×

Git Tech Talk

36,564 views

Published on

Quick overview of git.

Published in: Technology
0 Comments
14 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
36,564
On SlideShare
0
From Embeds
0
Number of Embeds
78
Actions
Shares
0
Downloads
0
Comments
0
Likes
14
Embeds 0
No embeds

No notes for slide
  • Git Tech Talk

    1. 1. git
    2. 2. git get git on board
    3. 3. git? • Version control system
    4. 4. git? • Version control system • Designed and developed by Linus Torvalds for Linux kernel development
    5. 5. git? • Version control system • Designed and developed by Linus Torvalds for Linux kernel development • Like Subversion, but better...
    6. 6. git? • Version control system • Designed and developed by Linus Torvalds for Linux kernel development • Like Subversion, but better... • How???
    7. 7. git > svn
    8. 8. git > svn
    9. 9. git > svn • Distributed • Every git repository is self-contained and includes a complete history of commits. (i.e. `git clone ...` vs `svn checkout ...`)
    10. 10. git > svn • Distributed • Every git repository is self-contained and includes a complete history of commits. (i.e. `git clone ...` vs `svn checkout ...`) • You can commit/branch/merge locally. Read: Fast & offline.
    11. 11. git > svn • Distributed • Every git repository is self-contained and includes a complete history of commits. (i.e. `git clone ...` vs `svn checkout ...`) • You can commit/branch/merge locally. Read: Fast & offline. • No single point of failure.
    12. 12. git > svn • Distributed • Every git repository is self-contained and includes a complete history of commits. (i.e. `git clone ...` vs `svn checkout ...`) • You can commit/branch/merge locally. Read: Fast & offline. • No single point of failure. • No “latest revision”: unique revision ID
    13. 13. git > svn • Lightweight Branching • Branch and merge often (per feature?)
    14. 14. git > svn • Lightweight Branching • Branch and merge often (per feature?) • Intelligent 3-way merging = rarely manual
    15. 15. git > svn • Lightweight Branching • Branch and merge often (per feature?) • Intelligent 3-way merging = rarely manual
    16. 16. git > svn • Small Space Requirements • Ex: Mozilla: SVN:12GB => git:420MB
    17. 17. git > svn • git submodules vs svn externals • Not covered in this presentation
    18. 18. A couple new concepts • “Remote” or “upstream”: A remotely accessible repository. • Push to a remote • Pull from a remote
    19. 19. A couple new concepts • “Staging area” or “index”: What will go into your next commit. • Example: • mate new_file.rb <= not staged • git add new_file.rb <= staged • git commit -a -m “Added a new file.” • Staging area is now empty.
    20. 20. Everything clear?
    21. 21. Get Started
    22. 22. Get Git Started
    23. 23. Get Git Started • Yes, I know it’s getting gitting old
    24. 24. Get Git Started • Install on OSX • git-osx-installer - Recommended. • OR • sudo port install git-core +svn +doc +bash_completion +gitweb
    25. 25. Get Git Started • Configure your user • git config --global user.name "Bobby SV" • git config --global user.email "bob@sv.com"
    26. 26. git commands: basics git init Initialize a git repository. git add Add files to a repository. git diff Generate a diff. git status Show uncommitted changes to the current project. git rm Remove a file from a repository. git mv Moves a file within a repository. git commit Commits staged changes. Use ‘-a’ to automatically stage every file that is already tracked before doing the commit. git log View a log of commits. git blame Show what revision and author last modified each line of a file. git show View the contents of a file, the listing of a directory or a commit.
    27. 27. git commands: branches git tag -a name Add a tag with the indicated name. git tag -l List tags. git push --tags Push tags to remote. git branch name Create a branch with the indicated name. git checkout name Switches to the branch ‘name’. git branch -a List branches (current branch indicated with ‘*’). git merge name Merge changes from branch name into the current branch. git cherry-pick rev Apply the changes in revision rev and commit to the current branch. git branch -d name Deletes the named branch.
    28. 28. git commands: remote git clone url Clone a repository. Sets up master branch w/ origin remote. git fetch Fetch updates from a remote repository. git pull git fetch + git merge - Use this more often than either alone. git remote List remotes. git push remote local_branch Push changes to remote. (remote & local_branch are optional) git remote add url Add a remote branch to the repository at url. git remote show remote Shows the branches in the remote repository.
    29. 29. git commands: advanced git checkout --track -b branch origin/ Create a corresponding local branch which will "track" the remote branch branch git stash Store uncommitted changes and reverts to HEAD. git rebase Provides fine-grained control of commits. Allows you to take all the changes that were committed on one branch and replay them on another one. git revert Undo a previous commit. Very different from `svn revert file` (which would be done with `git checkout file`or `git reset --hard HEAD`) git format-patch Prepare a patch for other developers. git fsck Check for errors. git gc --prune Cleanup repository. git grep “foo()” Search working directory for foo(). git merge --squash branch Represent many commits as one commit. git whatchanged Show the differences between commits. git show HEAD~4 HEAD~4 is short for HEAD^^^^. Each ‘^’ represents a parent revision.
    30. 30. overwhelmed?
    31. 31. git workflowz
    32. 32. Flow #1: simple/local • cd project_cornice • git init • Set up your ignores (next slide) • git add . • git commit -a -m "Initial import." • mate file.rb (make changes) • git commit -a -m "Make file better."
    33. 33. Flow #1: simple/local • More on .gitignore files • Like SVN’s `svn propset ignore` • For example, in project root, add .gitignore containing: • log/*.log • tmp/**/*
    34. 34. Flow #2: local with branches (master)$ git branch test_branch (master)$ git checkout test_branch Switched to branch "test_branch" (test_branch)$ mate README (test_branch)$ git commit -a -m "Improved file significantly." [test_branch 6bba901] Improved file significantly. 1 files changed, 1 insertions(+), 0 deletions(-) (test_branch)$ git checkout master Switched to branch "master" (master)$ git merge test_branch Updating 197ab8c..6bba901 Fast forward README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
    35. 35. Flow #3: remotes • git clone git@github.com:rangsikitpho/cornice.git • cd cornice • mate new_file.rb • git add new_file.rb • git commit -a -m “Did something amazing.” • git push [origin] [master]
    36. 36. Flow #4: full cycle • git clone git@github.com:rangsikitpho/cornice.git • cd cornice • git checkout -b feature_branch • mate new_file.rb • git add new_file.rb • git commit -a -m “Did something amazing.” • git checkout master • git merge feature_branch • git push [origin] [master] • git pull [origin] [master]
    37. 37. Flow #4: full cycle • git clone git@github.com:rangsikitpho/cornice.git • cd cornice • git checkout -b feature_branch • mate new_file.rb Virtuous • git add new_file.rb Cycle • git commit -a -m “Did something amazing.” • git checkout master • git merge feature_branch • git push [origin] [master] • git pull [origin] [master]
    38. 38. Bonus!!! • Have dropbox? (http://dropbox.com) • Use it as a remote! • How? • Main computer, from existing repository: • $ git clone --bare . ~/Dropbox/code/repo.git • $ git remote add dropbox ~/Dropbox/code/repo.git • $ git push dropbox master • Another computer: • $ git clone ~/Dropbox/code/repo.git • $ git remote add dropbox ~/Dropbox/code/repo.git • $ git pull dropbox master
    39. 39. Refs • git-osx-installer: • http://code.google.com/p/git-osx-installer/ • git branch info on command prompt • e.g. [bob:~/code/cornice(master)]$ • http://gist.github.com/283341 • OSX GUI • gitnub: http://wiki.github.com/Caged/gitnub/ • gitx: http://gitx.frim.nl/ • git textmate bundle • http://github.com/jcf/git-tmbundle • git tutorial • http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html • http://progit.org/book/ch3-6.html (In depth explanation of ‘git rebase’)

    ×