$30 off During Our Annual Pro Sale. View Details »

Version Control Using Git, Part I

Version Control Using Git, Part I

Part I of Version Control Using Git

Clay Wells

June 13, 2013
Tweet

More Decks by Clay Wells

Other Decks in Technology

Transcript

  1. Version Control Using Git, I
    https://dbe.med.upenn.edu/biostat-research/ClayWells
    @ClayWells

    View Slide

  2. Version Control Using Git, I
    Git is a free and open source distributed version control system.
    Version control is a system that records changes to a file or set of
    files over time so that you can recall specific versions later.
    http://git-scm.com/book/en/Getting-Started-About-Version-Control

    View Slide

  3. Version Control Using Git, I
    Any workflow
    Because of Git's distributed nature and branching system, an
    almost endless number of workflows can be implemented with
    relative ease.

    View Slide

  4. Version Control Using Git, I
    Dictator and lieutenants workflow

    View Slide

  5. Version Control Using Git, I
    Integration manager workflow

    View Slide

  6. Version Control Using Git, I
    Centralized workflow

    View Slide

  7. Version Control Using Git, I
    Download
    http://git-scm.com/downloads
    Getting Started
    http://git-scm.com/book/en/Getting-Started

    View Slide

  8. Version Control Using Git, I
    Create an empty repository
    git init
    git add .
    git commit -m 'add initial project'

    View Slide

  9. Version Control Using Git, I
    Create README.txt
    vi README.txt
    i to enter edit mode
    esc to exit edit mode
    :qw to quit & write

    View Slide

  10. Version Control Using Git, I
    View repository status
    git status

    View Slide

  11. Version Control Using Git, I

    View Slide

  12. Version Control Using Git, I
    Staging area
    stage only portions of a modified file

    View Slide

  13. Version Control Using Git, I
    Staging area
    add all changes to all files

    View Slide

  14. Version Control Using Git, I
    Add untracked files
    git add README.txt

    View Slide

  15. Version Control Using Git, I
    Commit modified files
    git commit README.txt
    git commit -a
    enter commit log message

    View Slide

  16. Version Control Using Git, I
    Rinse, Lather, Repeat
    create file – track
    git add file – stage
    git commit file - commit

    View Slide

  17. Version Control Using Git, I
    Ignore files
    cat .gitignore
    *.[oa]
    *~

    View Slide

  18. Version Control Using Git, I
    Feeling... ?

    View Slide

  19. Version Control Using Git, I
    Git can tag points in history as being important.
    Git uses two main types of tags:
    lightweight & annotated

    View Slide

  20. Version Control Using Git, I
    Lightweight tags
    Just a pointer to a specific commit.
    Creating a lightweight tag
    git tag v0.1-stable-lw

    View Slide

  21. Version Control Using Git, I
    Annotated tags (recommended)
    Stored as full objects in the Git database
    They’re checksummed;
    contain the tagger name, e-mail, and date;
    have a tagging message;
    can be signed and verified with GNU Privacy Guard (GPG).

    View Slide

  22. Version Control Using Git, I
    Creating an annotated tag
    git tag -a v0.1-stable -m 'version 0.1 is stable'
    List Tags
    git tag

    View Slide

  23. Version Control Using Git, I
    Show tag data
    git show v0.1-stable

    View Slide

  24. Version Control Using Git, I
    Commit log
    git log
    git log -p -2
    git log –pretty=oneline

    View Slide

  25. Version Control Using Git, I
    Git tree roles
    The HEAD - last commit snapshot, next parent
    The Index - proposed next commit snapshot
    The Working Directory - sandbox

    View Slide

  26. Version Control Using Git, I
    Revert
    git revert HEAD
    git revert $commit-id

    View Slide

  27. Version Control Using Git, I
    Tagging later
    git show –pretty=oneline
    git tag -a v0.2-ready -m 'v0.2 is ready' $commit-id

    View Slide

  28. Version Control Using Git, I
    Renaming a file
    cp example.txt example.md
    git rm example.txt
    git add example.md
    git commit -m 'renaming a file'

    View Slide

  29. Version Control Using Git, I
    Removing a file
    git rm example.txt
    git commit -m 'removing example.txt'

    View Slide

  30. Version Control Using Git, I
    Server workflow (origin)
    git clone ssh://[email protected]/project.git
    ...
    git push
    git push --tags
    More in Version Control Using Git, II

    View Slide

  31. Version Control Using Git, I
    Feeling... ?

    View Slide

  32. Version Control Using Git, I
    Working with a Git GUI
    SourceTree:
    http://www.sourcetreeapp.com
    - example demonstration -

    View Slide

  33. Version Control Using Git, I
    Resources
    Git Website - http://git-scm.com
    Git Documentation - http://git-scm.com/doc
    Git Book (on-line, PDF) - http://git-scm.com/book
    Git GUI - http://www.sourcetreeapp.com

    View Slide

  34. Version Control Using Git, I
    Git ROCKS!!!
    Questions?

    View Slide