SlideShare ist ein Scribd-Unternehmen logo
1 von 67
Downloaden Sie, um offline zu lesen
Git
        For the Android Developer
        Tony Hillerson, AnDevCon Spring 2012
        #AnDevCon @tackmobile @thillerson
        http://www.slideshare.net/thillerson/git-for-android-developers
PRESENTATION                                                     ANDEVCON • MAY 14, 2012
About Me
 •   Worked with Android and Git for a few years now
 •   O’Reilly Screencaster: Developing Android Applications
 •   http://training.oreilly.com/androidapps/
                •   http://training.oreilly.com/androidapps2/
 •   Tech Reviewer




 PRESENTATION                                                   tackmobile.com
Diving Right In
        Learning by Doing




PRESENTATION                ANDEVCON • MAY 14, 2012
git                      git
                     or   clone
   init


                           git
                                  git commit   86650c185eda50c9f9d58e2fbdf8b7113e5dee54
           changes        add

                           git
                                  git commit   6facfd9f34173f4fb024196996e948a87c85eb56
           changes        add

                           git
                                  git commit   b02ef5bf190e28ba24eab3ffab6133181cb5b5ef
           changes        add



                ...   ∞

PRESENTATION                                                                      tackmobile.com
.gitignore
 •   Can be nested deeply
 •   https://github.com/github/gitignore




 PRESENTATION                              tackmobile.com
Git Log - The Project’s History
 •   What got committed?
 •   Commit messages
 •   Content
 •   When? Who?




 PRESENTATION                     tackmobile.com
Remotes
 •   remote add
 •   clone
 •   fetch
 •   pull
 •   push




 PRESENTATION     tackmobile.com
Tagging
                            git tag -a -m"Tagging v1.0" v1.0 c5083fa

                   master



         fb4f5d9            c5083fa   3f43fa3




    •      Both “-v1.0” and c5083fa will point to c5083fa

    •      Push this tag with `git push --tags`

    •      Can be cryptologically signed
 PRESENTATION                                                          tackmobile.com
Recap of Simple Commands
 •   git init - Creates an empty Git repository
 •   git add - Adds a file to the stage (“stages a file”)
 •   git rm - Removes from version control
 •   git commit - Commits the staged changes to the (local) repository
 •   git log - A view of the history
 •   git tag - Names a commit
 •   .gitignore - tells git to ignore certain files

 PRESENTATION                                                       tackmobile.com
Why Source Control?
 •   For the solo developer?
     •   Protection against mistakes
     •   Freedom
          •     ... to refactor
          •     ... to experiment
 •   For the development team?
     •   All of the above, plus:
     •   Parallel development
     •   Merging different code branches

 PRESENTATION                              tackmobile.com
Preliminaries
        Getting Git and Getting Set Up




PRESENTATION                             ANDEVCON • MAY 14, 2012
What’s a Git?
  A completely ignorant, childish person with no
  manners.                        - http://urbandictionary.com




                                    Linus Torvalds
 PRESENTATION        http://en.wikipedia.org/wiki/Linus_Torvalds   tackmobile.com
What’s a Git?


                  Git is a free & open source, distributed
                version control system designed to handle
                everything from small to very large projects
                          with speed and efficiency.
                                               - http://git-scm.com




 PRESENTATION                                                         tackmobile.com
Getting Set Up on Mac
 •   Homebrew - http://mxcl.github.com/homebrew/
     •   brew install git

 •   MacPorts - http://www.macports.org/




 PRESENTATION                                      tackmobile.com
Getting Set Up on Windows
 •   msysgit -http://code.google.com/p/msysgit/




 PRESENTATION                                     tackmobile.com
Getting Set Up on Linux
 •   apt, etc - you probably know the drill




 PRESENTATION                                 tackmobile.com
Gooies!
          Git Tower - http://git-tower.com
                                                                                                          M
      •

      •   Source Tree - Mac App Store                                                                     A
      •   Brother Bard’s GitX fork - http://brotherbard.com/blog/2010/03/experimental-gitx-fork/          C
      •    Tortoise Git - http://code.google.com/p/tortoisegit/                                            W
                                                                                                           I
                                                                                                           N


 PRESENTATION                                                                                      tackmobile.com
Eclipse Integration
       •   http://www.eclipse.org/egit/




 PRESENTATION                             tackmobile.com
Reference
 •   Git - http://git-scm.com/
 •   ProGit - http://progit.org/book/ - Scott Chacon
 •   Insider Guide to Github -
     http://www.pragprog.com/screencasts/v-scgithub/insider-guide-to-
     github - Scott Chacon




 PRESENTATION                                                     tackmobile.com
The Command Line
        A Short Sermon




PRESENTATION               ANDEVCON • MAY 14, 2012
The Guts of Git
        The Little Bits that Make Git Different




PRESENTATION                                      ANDEVCON • MAY 14, 2012
What’s With all the Characters?
           86650c185eda50c9f9d58e2fbdf8b7113e5dee54
 •   SHA1 Hash
 •   Uniquely identifies a commit
 •   Secure - very unlikely that someone can tamper with content in a
     repository




 PRESENTATION                                                           tackmobile.com
SHA-1 Hash Keys




        “       ... to have a probability of a SHA1-hash
                     collision rise to 1/2, you need about
                                          10^24 objects ...
                                     - Scott Chacon in Pro Git (paraphrased)




 PRESENTATION                                                                  tackmobile.com
In Git There Are Only...
 •   Blobs
 •   Trees
 •   Commits




 PRESENTATION              tackmobile.com
Blobs
 •   The contents of your files are stored as binary files in .git/objects
 •   Git is efficient. It only stores the same content once.
 •   Identified by a SHA-1
 •   Show blob contents with e.g. git show c7fb9f5




 PRESENTATION                                                                tackmobile.com
Trees
 •   Trees give structure to blobs
 •   Trees are also stored in .git/objects
 •   Identified by SHA-1
 •   View a tree with ls-tree, e.g. `git ls-tree HEAD`




 PRESENTATION                                            tackmobile.com
Commits
•   Identified by a SHA-1
•   Points to one tree
•   Has a required message
•   May have one (or more) parent commit(s)
•   Show the reachable commits from a commit: git rev-list HEAD




 PRESENTATION                                                     tackmobile.com
Refs
 •   Point to commits
 •   .git/refs/heads - the latest commits in local branches
 •   HEAD - the latest commit on the current branch




 PRESENTATION                                                 tackmobile.com
Blobs Are Content


                     b84ed8ed


                                e8d5cf6
                579a3b1




 PRESENTATION                             tackmobile.com
Trees Give Structure
     9899d2c

                 b84ed8ed   foo.txt

                 579a3b1    bar.txt

                 e8d5cf6    baz.html
                                       trees can point
                3ffb35b     /images     to other trees




 PRESENTATION                                            tackmobile.com
Commits Point to Trees

                  d414c3e                     9899d2c
                “Updated the main activity”

                                                         b84ed8ed   foo.txt

                                                         579a3b1    bar.txt

                                                         e8d5cf6    baz.html

                                                        3ffb35b /images


 PRESENTATION                                                                  tackmobile.com
Commits Have Parents

                       d414c3e
                       “Updated the main activity”




                       090c953
                            “Fixed bug #42”




                       4493671
                         “Added RoboGuice”




                       c1d1f60
                            “Initial commit”




 PRESENTATION                                        tackmobile.com
Refs Point to Commits

                HEAD    d414c3e
                        “Updated the main activity”




                        090c953
                             “Fixed bug #42”




                        4493671
                          “Added RoboGuice”




                        c1d1f60
                             “Initial commit”




 PRESENTATION                                         tackmobile.com
And That’s All You
               Need To Know About
                       Git

PRESENTATION                         tackmobile.com
And That’s All You
               Need To Know About
                       Git
                       (Mostly)




PRESENTATION                         tackmobile.com
Sweet Moves with Git
        Sweet, Sweet Moves




PRESENTATION                   ANDEVCON • MAY 14, 2012
Interactive Add
        Building Semantic Commits




PRESENTATION                        ANDEVCON • MAY 14, 2012
Interactive Add - Building Semantic Commits
 •   `git add` simply adds to the stage
 •   `git commit -a` will commit all changes to tracked files (add and
     commit)
 •   `git add -i` -- a command line tool to interactively add changes
 •   Individual commits shouldn’t leave things broken
 •   Try to commit some useful feature or bug fix all together




 PRESENTATION                                                            tackmobile.com
Amending A Commit
        Fix the Last Commit




PRESENTATION                  ANDEVCON • MAY 14, 2012
git commit --amend
 •   Oops! I misspelled something in the commit message
 •   Oops! I did `git commit -a` and forgot to `git add` a file
 •   Oops! I just committed a bug
 •   USE ONLY BEFORE YOU SHARE CHANGES




 PRESENTATION                                                     tackmobile.com
Git Revert
        More Like Git Reverse




PRESENTATION                    ANDEVCON • MAY 14, 2012
git revert
 •   Commits the reverse of a commit
 •   The previous commit is still there
 •   != svn revert




 PRESENTATION                             tackmobile.com
Git Stash
        Like a Little Repo In Your Repo




PRESENTATION                              ANDEVCON • MAY 14, 2012
git stash
 •   remember: git help stash
 •   Stash away changes in a safe place




 PRESENTATION                             tackmobile.com
Branching
        Hitting Save Before You Fight the Level Boss




PRESENTATION                                           ANDEVCON • MAY 14, 2012
Branching
 •   checkout -b
 •   merging
 •   rebasing




 PRESENTATION      tackmobile.com
How To Think About Branching
 •   Mainline
     •   What do you want “master” to mean?
 •   Topic Branches
 •   Branching examples




 PRESENTATION                                 tackmobile.com
Topic Branches
 •   Branching is about controlling feature sets
 •   Make a new branch for a story
 •   Make a new branch for a bug fix
 •   Make a new branch to spike something




 PRESENTATION                                      tackmobile.com
Team Branching Strategies
 •   What do you want “master” to mean?
 •   Keep master deployable?
     •   one strategy for web software
 •   Use “master” as an integration branch?
     •   Each developer uses topic branches and integrates to master
     •   Make a branch for releases



 PRESENTATION                                                          tackmobile.com
Branching
     git checkout -b add_login_activity

                   master



         fb4f5d9            c5083fa




                                      add_login_activity



                                      9aa8827              fe594ce   ccb6f5e




 PRESENTATION                                                                  tackmobile.com
Branching: Merging
                                         git checkout master
                                         git merge add_login_activity

                   master


                                                                               9aa8827   fe594ce   ccb6f5e
         fb4f5d9            c5083fa             3f43fa3




                                      add_login_activity



                                        9aa8827            fe594ce   ccb6f5e




 PRESENTATION                                                                                      tackmobile.com
Branching: Rebasing
                  master


       fb4f5d9             c5083fa      3f43fa3



                                       add_login_activity


                 before              9aa8827           fe594ce            ccb6f5e



                  master


      fb4f5d9              c5083fa      3f43fa3



                                                            add_login_activity


                         after                              9aa8827              fe594ce   ccb6f5e
                 `git rebase master`
 PRESENTATION                                                                                        tackmobile.com
Branching: Rebasing
 •   Better than merging in some ways...
 •   Don’t use if you’ve pushed your branch to a remote
     •   Can override with `git push -force`




 PRESENTATION                                             tackmobile.com
Git Pull --rebase
 •   Also available: `git pull --rebase`
     •   Helpful for avoiding merge commits
     •   May cause problems if git can’t automatically merge
          •     `git reset HEAD` and start over with normal `git pull`




 PRESENTATION                                                            tackmobile.com
Cherry Pick
        I’ll Take One Of Those... And One Of Those...




PRESENTATION                                            ANDEVCON • MAY 14, 2012
Cherry-pick
      git cherry-pick fe594ce
                                                                      A new commit with
                   master                                              the changes from
                                                                            fe594ce

         fb4f5d9            c5083fa               3f43fa3




                                      add_login_activity



                                        9aa8827             fe594ce             ccb6f5e




 PRESENTATION                                                                             tackmobile.com
Interactive Rebase
        Rewrite History




PRESENTATION                 ANDEVCON • MAY 14, 2012
Interactive Rebase - Fixing History
 •   git rebase -i [commit]
 •   A list of all commits in the current order
 •   Reorder
 •   Fix a certain commit
 •   Squash commits together
 •   Delete commits
 •   DON’T USE AFTER YOU’VE PUSHED


 PRESENTATION                                     tackmobile.com
Whoops!
        Lots Of Ways To Fix It




PRESENTATION                     ANDEVCON • MAY 14, 2012
git checkout
 •   `git checkout [filename]` = remove all unstaged changes




 PRESENTATION                                                  tackmobile.com
git reset
 •   `git reset [filename]` = opposite of `git add [filename]`
 •   `git reset HEAD` = same as above - acts on all changes
 •   `git reset HEAD^` (also ^^, or ~1, ~42, etc.) = rollback commits to
     working tree
 •   All examples of “mixed” reset




 PRESENTATION                                                          tackmobile.com
git reset soft
 •   git reset --soft [commit]
 •   Moves HEAD to commit
 •   Puts the “popped” contents on the index




 PRESENTATION                                  tackmobile.com
git reset mixed (default)
 •   git reset [commit]
 •   Moves HEAD to commit
 •   Puts the “popped” contents on the index
 •   Moves the index to the working tree as changes




 PRESENTATION                                         tackmobile.com
git reset hard
 •   git reset --hard [commit]
 •   Moves HEAD to commit
 •   Puts the “popped” contents on the index
 •   Moves the index to the working tree as changes
 •   Makes the working tree look like the index
 •   DESTRUCTIVE



 PRESENTATION                                         tackmobile.com
git reset use cases
 •   Back that last commit up (git reset HEAD^)
 •   Don’t forget `commit --amend`
 •   Oops, didn’t mean to commit that file
 •   I meant that commit to be on a branch!




 PRESENTATION                                     tackmobile.com
The Take Home
 •   SCM Is Important
 •   No matter what kind of developer you are
 •   Git is fundamentally different from the others
 •   It’s not a database of patches
 •   It’s a history of filesystem snapshots
 •   It gives you freedom to innovate, make mistakes, and collaborate.



 PRESENTATION                                                        tackmobile.com
Thank you!
                                             #AnDevCon
                                             @tackmobile
                                              @thillerson
                                    http://github.com/thillerson
                                  http://slideshare.com/thillerson




               For the Android Developer • Tony Hillerson • AnDevCon Spring 2012
PRESENTATION                                                                       tackmobile.com

Weitere ähnliche Inhalte

Was ist angesagt?

Inside GitHub
Inside GitHubInside GitHub
Inside GitHuberr
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Wonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSWonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSVlatko Kosturjak
 
Ripping web accessible .git files
Ripping web accessible .git filesRipping web accessible .git files
Ripping web accessible .git filesVlatko Kosturjak
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Creating new Tizen profiles using the Yocto Project
Creating new Tizen profiles  using the Yocto ProjectCreating new Tizen profiles  using the Yocto Project
Creating new Tizen profiles using the Yocto ProjectLeon Anavi
 
Git & e git beginner workshop
Git & e git beginner workshopGit & e git beginner workshop
Git & e git beginner workshopIgor Laborie
 
Why You Should Be Using Git
Why You Should Be Using GitWhy You Should Be Using Git
Why You Should Be Using GitFrancisco Vieira
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitAmit Mathur
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidVlatko Kosturjak
 
遺失的時代精神 - Zeitgeist and GNOME Activity Journal
遺失的時代精神 - Zeitgeist and GNOME Activity Journal遺失的時代精神 - Zeitgeist and GNOME Activity Journal
遺失的時代精神 - Zeitgeist and GNOME Activity JournalRex Tsai
 
Get your FLOSS problems solved
Get your FLOSS problems solvedGet your FLOSS problems solved
Get your FLOSS problems solvedRex Tsai
 
PHARO IoT: Present and Future
PHARO IoT: Present and FuturePHARO IoT: Present and Future
PHARO IoT: Present and FutureESUG
 
RootedCON 2017 - Docker might not be your friend. Trojanizing Docker images
RootedCON 2017 - Docker might not be your friend. Trojanizing Docker imagesRootedCON 2017 - Docker might not be your friend. Trojanizing Docker images
RootedCON 2017 - Docker might not be your friend. Trojanizing Docker imagesDaniel Garcia (a.k.a cr0hn)
 
Podcasting and Multimedia with Plone
Podcasting and Multimedia with PlonePodcasting and Multimedia with Plone
Podcasting and Multimedia with PloneJazkarta, Inc.
 

Was ist angesagt? (17)

Inside GitHub
Inside GitHubInside GitHub
Inside GitHub
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Wonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSWonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCS
 
Ripping web accessible .git files
Ripping web accessible .git filesRipping web accessible .git files
Ripping web accessible .git files
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git Presentation
Git PresentationGit Presentation
Git Presentation
 
Creating new Tizen profiles using the Yocto Project
Creating new Tizen profiles  using the Yocto ProjectCreating new Tizen profiles  using the Yocto Project
Creating new Tizen profiles using the Yocto Project
 
Git & e git beginner workshop
Git & e git beginner workshopGit & e git beginner workshop
Git & e git beginner workshop
 
Why You Should Be Using Git
Why You Should Be Using GitWhy You Should Be Using Git
Why You Should Be Using Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
 
遺失的時代精神 - Zeitgeist and GNOME Activity Journal
遺失的時代精神 - Zeitgeist and GNOME Activity Journal遺失的時代精神 - Zeitgeist and GNOME Activity Journal
遺失的時代精神 - Zeitgeist and GNOME Activity Journal
 
Get your FLOSS problems solved
Get your FLOSS problems solvedGet your FLOSS problems solved
Get your FLOSS problems solved
 
PHARO IoT: Present and Future
PHARO IoT: Present and FuturePHARO IoT: Present and Future
PHARO IoT: Present and Future
 
RootedCON 2017 - Docker might not be your friend. Trojanizing Docker images
RootedCON 2017 - Docker might not be your friend. Trojanizing Docker imagesRootedCON 2017 - Docker might not be your friend. Trojanizing Docker images
RootedCON 2017 - Docker might not be your friend. Trojanizing Docker images
 
Podcasting and Multimedia with Plone
Podcasting and Multimedia with PlonePodcasting and Multimedia with Plone
Podcasting and Multimedia with Plone
 

Andere mochten auch

Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android DeveloperEffective
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developersmpvanwinkle
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developersAidan Casey
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developersAdam Culp
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developersDmitry Guyvoronsky
 
[Easy] How to use Evernote: Beginner's Guide
[Easy]  How to use Evernote: Beginner's Guide[Easy]  How to use Evernote: Beginner's Guide
[Easy] How to use Evernote: Beginner's GuideAna Uy
 
DATAS Technolody may2016 eng AK
DATAS Technolody may2016 eng AKDATAS Technolody may2016 eng AK
DATAS Technolody may2016 eng AKAlexey Kononenko
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android DeveloperEffectiveUI
 
Platform freelance ASP .NET / C#
Platform freelance ASP .NET / C# Platform freelance ASP .NET / C#
Platform freelance ASP .NET / C# Saâd Zerhouni
 

Andere mochten auch (11)

Kelk
KelkKelk
Kelk
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 
Evernote
EvernoteEvernote
Evernote
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developers
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developers
 
[Easy] How to use Evernote: Beginner's Guide
[Easy]  How to use Evernote: Beginner's Guide[Easy]  How to use Evernote: Beginner's Guide
[Easy] How to use Evernote: Beginner's Guide
 
DATAS Technolody may2016 eng AK
DATAS Technolody may2016 eng AKDATAS Technolody may2016 eng AK
DATAS Technolody may2016 eng AK
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 
Platform freelance ASP .NET / C#
Platform freelance ASP .NET / C# Platform freelance ASP .NET / C#
Platform freelance ASP .NET / C#
 

Ähnlich wie Git for Android Developers

Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android DevelopersTony Hillerson
 
maksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your cimaksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your ciDariia Seimova
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubBigBlueHat
 
Why Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysWhy Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysCarlos Taborda
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexyAilsa126
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015mwrather
 
Nicolás Aravena - Cómo aprender Git y no morir en el intento
Nicolás Aravena - Cómo aprender Git y no morir en el intentoNicolás Aravena - Cómo aprender Git y no morir en el intento
Nicolás Aravena - Cómo aprender Git y no morir en el intento9punto5
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An IntroductionBehzad Altaf
 
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -EssentialsJAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentialsjazoon13
 

Ähnlich wie Git for Android Developers (20)

Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android Developers
 
Working with Git
Working with GitWorking with Git
Working with Git
 
maksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your cimaksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your ci
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Git'in on Windows
Git'in on WindowsGit'in on Windows
Git'in on Windows
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Why Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysWhy Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anyways
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
 
Git in 5 Minutes
Git in 5 MinutesGit in 5 Minutes
Git in 5 Minutes
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
 
3 Git
3 Git3 Git
3 Git
 
Nicolás Aravena - Cómo aprender Git y no morir en el intento
Nicolás Aravena - Cómo aprender Git y no morir en el intentoNicolás Aravena - Cómo aprender Git y no morir en el intento
Nicolás Aravena - Cómo aprender Git y no morir en el intento
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git! Why? How?
Git! Why? How?Git! Why? How?
Git! Why? How?
 
Git 101 for_tarad_dev
Git 101 for_tarad_devGit 101 for_tarad_dev
Git 101 for_tarad_dev
 
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -EssentialsJAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
 
Talk to git
Talk to gitTalk to git
Talk to git
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Git Heaven with Wakanda
Git Heaven with WakandaGit Heaven with Wakanda
Git Heaven with Wakanda
 
Git Basics Philips
Git Basics PhilipsGit Basics Philips
Git Basics Philips
 

Mehr von Tack Mobile

Assembly • Creative Mornings
Assembly • Creative MorningsAssembly • Creative Mornings
Assembly • Creative MorningsTack Mobile
 
Introduction to Hardware with littleBits
Introduction to Hardware with littleBitsIntroduction to Hardware with littleBits
Introduction to Hardware with littleBitsTack Mobile
 
Prototyping with Framer.js
Prototyping with Framer.jsPrototyping with Framer.js
Prototyping with Framer.jsTack Mobile
 
Adrift: The Making of an iOS Game
Adrift: The Making of an iOS GameAdrift: The Making of an iOS Game
Adrift: The Making of an iOS GameTack Mobile
 
Dynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesDynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesTack Mobile
 
Advanced Android Design Implementation
Advanced Android Design ImplementationAdvanced Android Design Implementation
Advanced Android Design ImplementationTack Mobile
 
Scala for android
Scala for androidScala for android
Scala for androidTack Mobile
 
Designing an Android App from Idea to Market
Designing an Android App from Idea to MarketDesigning an Android App from Idea to Market
Designing an Android App from Idea to MarketTack Mobile
 
Mobile Means Business
Mobile Means BusinessMobile Means Business
Mobile Means BusinessTack Mobile
 

Mehr von Tack Mobile (9)

Assembly • Creative Mornings
Assembly • Creative MorningsAssembly • Creative Mornings
Assembly • Creative Mornings
 
Introduction to Hardware with littleBits
Introduction to Hardware with littleBitsIntroduction to Hardware with littleBits
Introduction to Hardware with littleBits
 
Prototyping with Framer.js
Prototyping with Framer.jsPrototyping with Framer.js
Prototyping with Framer.js
 
Adrift: The Making of an iOS Game
Adrift: The Making of an iOS GameAdrift: The Making of an iOS Game
Adrift: The Making of an iOS Game
 
Dynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesDynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and Games
 
Advanced Android Design Implementation
Advanced Android Design ImplementationAdvanced Android Design Implementation
Advanced Android Design Implementation
 
Scala for android
Scala for androidScala for android
Scala for android
 
Designing an Android App from Idea to Market
Designing an Android App from Idea to MarketDesigning an Android App from Idea to Market
Designing an Android App from Idea to Market
 
Mobile Means Business
Mobile Means BusinessMobile Means Business
Mobile Means Business
 

Kürzlich hochgeladen

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Kürzlich hochgeladen (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

Git for Android Developers

  • 1. Git For the Android Developer Tony Hillerson, AnDevCon Spring 2012 #AnDevCon @tackmobile @thillerson http://www.slideshare.net/thillerson/git-for-android-developers PRESENTATION ANDEVCON • MAY 14, 2012
  • 2. About Me • Worked with Android and Git for a few years now • O’Reilly Screencaster: Developing Android Applications • http://training.oreilly.com/androidapps/ • http://training.oreilly.com/androidapps2/ • Tech Reviewer PRESENTATION tackmobile.com
  • 3. Diving Right In Learning by Doing PRESENTATION ANDEVCON • MAY 14, 2012
  • 4. git git or clone init git git commit 86650c185eda50c9f9d58e2fbdf8b7113e5dee54 changes add git git commit 6facfd9f34173f4fb024196996e948a87c85eb56 changes add git git commit b02ef5bf190e28ba24eab3ffab6133181cb5b5ef changes add ... ∞ PRESENTATION tackmobile.com
  • 5. .gitignore • Can be nested deeply • https://github.com/github/gitignore PRESENTATION tackmobile.com
  • 6. Git Log - The Project’s History • What got committed? • Commit messages • Content • When? Who? PRESENTATION tackmobile.com
  • 7. Remotes • remote add • clone • fetch • pull • push PRESENTATION tackmobile.com
  • 8. Tagging git tag -a -m"Tagging v1.0" v1.0 c5083fa master fb4f5d9 c5083fa 3f43fa3 • Both “-v1.0” and c5083fa will point to c5083fa • Push this tag with `git push --tags` • Can be cryptologically signed PRESENTATION tackmobile.com
  • 9. Recap of Simple Commands • git init - Creates an empty Git repository • git add - Adds a file to the stage (“stages a file”) • git rm - Removes from version control • git commit - Commits the staged changes to the (local) repository • git log - A view of the history • git tag - Names a commit • .gitignore - tells git to ignore certain files PRESENTATION tackmobile.com
  • 10. Why Source Control? • For the solo developer? • Protection against mistakes • Freedom • ... to refactor • ... to experiment • For the development team? • All of the above, plus: • Parallel development • Merging different code branches PRESENTATION tackmobile.com
  • 11. Preliminaries Getting Git and Getting Set Up PRESENTATION ANDEVCON • MAY 14, 2012
  • 12. What’s a Git? A completely ignorant, childish person with no manners. - http://urbandictionary.com Linus Torvalds PRESENTATION http://en.wikipedia.org/wiki/Linus_Torvalds tackmobile.com
  • 13. What’s a Git? Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. - http://git-scm.com PRESENTATION tackmobile.com
  • 14. Getting Set Up on Mac • Homebrew - http://mxcl.github.com/homebrew/ • brew install git • MacPorts - http://www.macports.org/ PRESENTATION tackmobile.com
  • 15. Getting Set Up on Windows • msysgit -http://code.google.com/p/msysgit/ PRESENTATION tackmobile.com
  • 16. Getting Set Up on Linux • apt, etc - you probably know the drill PRESENTATION tackmobile.com
  • 17. Gooies! Git Tower - http://git-tower.com M • • Source Tree - Mac App Store A • Brother Bard’s GitX fork - http://brotherbard.com/blog/2010/03/experimental-gitx-fork/ C • Tortoise Git - http://code.google.com/p/tortoisegit/ W I N PRESENTATION tackmobile.com
  • 18. Eclipse Integration • http://www.eclipse.org/egit/ PRESENTATION tackmobile.com
  • 19. Reference • Git - http://git-scm.com/ • ProGit - http://progit.org/book/ - Scott Chacon • Insider Guide to Github - http://www.pragprog.com/screencasts/v-scgithub/insider-guide-to- github - Scott Chacon PRESENTATION tackmobile.com
  • 20. The Command Line A Short Sermon PRESENTATION ANDEVCON • MAY 14, 2012
  • 21. The Guts of Git The Little Bits that Make Git Different PRESENTATION ANDEVCON • MAY 14, 2012
  • 22. What’s With all the Characters? 86650c185eda50c9f9d58e2fbdf8b7113e5dee54 • SHA1 Hash • Uniquely identifies a commit • Secure - very unlikely that someone can tamper with content in a repository PRESENTATION tackmobile.com
  • 23. SHA-1 Hash Keys “ ... to have a probability of a SHA1-hash collision rise to 1/2, you need about 10^24 objects ... - Scott Chacon in Pro Git (paraphrased) PRESENTATION tackmobile.com
  • 24. In Git There Are Only... • Blobs • Trees • Commits PRESENTATION tackmobile.com
  • 25. Blobs • The contents of your files are stored as binary files in .git/objects • Git is efficient. It only stores the same content once. • Identified by a SHA-1 • Show blob contents with e.g. git show c7fb9f5 PRESENTATION tackmobile.com
  • 26. Trees • Trees give structure to blobs • Trees are also stored in .git/objects • Identified by SHA-1 • View a tree with ls-tree, e.g. `git ls-tree HEAD` PRESENTATION tackmobile.com
  • 27. Commits • Identified by a SHA-1 • Points to one tree • Has a required message • May have one (or more) parent commit(s) • Show the reachable commits from a commit: git rev-list HEAD PRESENTATION tackmobile.com
  • 28. Refs • Point to commits • .git/refs/heads - the latest commits in local branches • HEAD - the latest commit on the current branch PRESENTATION tackmobile.com
  • 29. Blobs Are Content b84ed8ed e8d5cf6 579a3b1 PRESENTATION tackmobile.com
  • 30. Trees Give Structure 9899d2c b84ed8ed foo.txt 579a3b1 bar.txt e8d5cf6 baz.html trees can point 3ffb35b /images to other trees PRESENTATION tackmobile.com
  • 31. Commits Point to Trees d414c3e 9899d2c “Updated the main activity” b84ed8ed foo.txt 579a3b1 bar.txt e8d5cf6 baz.html 3ffb35b /images PRESENTATION tackmobile.com
  • 32. Commits Have Parents d414c3e “Updated the main activity” 090c953 “Fixed bug #42” 4493671 “Added RoboGuice” c1d1f60 “Initial commit” PRESENTATION tackmobile.com
  • 33. Refs Point to Commits HEAD d414c3e “Updated the main activity” 090c953 “Fixed bug #42” 4493671 “Added RoboGuice” c1d1f60 “Initial commit” PRESENTATION tackmobile.com
  • 34. And That’s All You Need To Know About Git PRESENTATION tackmobile.com
  • 35. And That’s All You Need To Know About Git (Mostly) PRESENTATION tackmobile.com
  • 36. Sweet Moves with Git Sweet, Sweet Moves PRESENTATION ANDEVCON • MAY 14, 2012
  • 37. Interactive Add Building Semantic Commits PRESENTATION ANDEVCON • MAY 14, 2012
  • 38. Interactive Add - Building Semantic Commits • `git add` simply adds to the stage • `git commit -a` will commit all changes to tracked files (add and commit) • `git add -i` -- a command line tool to interactively add changes • Individual commits shouldn’t leave things broken • Try to commit some useful feature or bug fix all together PRESENTATION tackmobile.com
  • 39. Amending A Commit Fix the Last Commit PRESENTATION ANDEVCON • MAY 14, 2012
  • 40. git commit --amend • Oops! I misspelled something in the commit message • Oops! I did `git commit -a` and forgot to `git add` a file • Oops! I just committed a bug • USE ONLY BEFORE YOU SHARE CHANGES PRESENTATION tackmobile.com
  • 41. Git Revert More Like Git Reverse PRESENTATION ANDEVCON • MAY 14, 2012
  • 42. git revert • Commits the reverse of a commit • The previous commit is still there • != svn revert PRESENTATION tackmobile.com
  • 43. Git Stash Like a Little Repo In Your Repo PRESENTATION ANDEVCON • MAY 14, 2012
  • 44. git stash • remember: git help stash • Stash away changes in a safe place PRESENTATION tackmobile.com
  • 45. Branching Hitting Save Before You Fight the Level Boss PRESENTATION ANDEVCON • MAY 14, 2012
  • 46. Branching • checkout -b • merging • rebasing PRESENTATION tackmobile.com
  • 47. How To Think About Branching • Mainline • What do you want “master” to mean? • Topic Branches • Branching examples PRESENTATION tackmobile.com
  • 48. Topic Branches • Branching is about controlling feature sets • Make a new branch for a story • Make a new branch for a bug fix • Make a new branch to spike something PRESENTATION tackmobile.com
  • 49. Team Branching Strategies • What do you want “master” to mean? • Keep master deployable? • one strategy for web software • Use “master” as an integration branch? • Each developer uses topic branches and integrates to master • Make a branch for releases PRESENTATION tackmobile.com
  • 50. Branching git checkout -b add_login_activity master fb4f5d9 c5083fa add_login_activity 9aa8827 fe594ce ccb6f5e PRESENTATION tackmobile.com
  • 51. Branching: Merging git checkout master git merge add_login_activity master 9aa8827 fe594ce ccb6f5e fb4f5d9 c5083fa 3f43fa3 add_login_activity 9aa8827 fe594ce ccb6f5e PRESENTATION tackmobile.com
  • 52. Branching: Rebasing master fb4f5d9 c5083fa 3f43fa3 add_login_activity before 9aa8827 fe594ce ccb6f5e master fb4f5d9 c5083fa 3f43fa3 add_login_activity after 9aa8827 fe594ce ccb6f5e `git rebase master` PRESENTATION tackmobile.com
  • 53. Branching: Rebasing • Better than merging in some ways... • Don’t use if you’ve pushed your branch to a remote • Can override with `git push -force` PRESENTATION tackmobile.com
  • 54. Git Pull --rebase • Also available: `git pull --rebase` • Helpful for avoiding merge commits • May cause problems if git can’t automatically merge • `git reset HEAD` and start over with normal `git pull` PRESENTATION tackmobile.com
  • 55. Cherry Pick I’ll Take One Of Those... And One Of Those... PRESENTATION ANDEVCON • MAY 14, 2012
  • 56. Cherry-pick git cherry-pick fe594ce A new commit with master the changes from fe594ce fb4f5d9 c5083fa 3f43fa3 add_login_activity 9aa8827 fe594ce ccb6f5e PRESENTATION tackmobile.com
  • 57. Interactive Rebase Rewrite History PRESENTATION ANDEVCON • MAY 14, 2012
  • 58. Interactive Rebase - Fixing History • git rebase -i [commit] • A list of all commits in the current order • Reorder • Fix a certain commit • Squash commits together • Delete commits • DON’T USE AFTER YOU’VE PUSHED PRESENTATION tackmobile.com
  • 59. Whoops! Lots Of Ways To Fix It PRESENTATION ANDEVCON • MAY 14, 2012
  • 60. git checkout • `git checkout [filename]` = remove all unstaged changes PRESENTATION tackmobile.com
  • 61. git reset • `git reset [filename]` = opposite of `git add [filename]` • `git reset HEAD` = same as above - acts on all changes • `git reset HEAD^` (also ^^, or ~1, ~42, etc.) = rollback commits to working tree • All examples of “mixed” reset PRESENTATION tackmobile.com
  • 62. git reset soft • git reset --soft [commit] • Moves HEAD to commit • Puts the “popped” contents on the index PRESENTATION tackmobile.com
  • 63. git reset mixed (default) • git reset [commit] • Moves HEAD to commit • Puts the “popped” contents on the index • Moves the index to the working tree as changes PRESENTATION tackmobile.com
  • 64. git reset hard • git reset --hard [commit] • Moves HEAD to commit • Puts the “popped” contents on the index • Moves the index to the working tree as changes • Makes the working tree look like the index • DESTRUCTIVE PRESENTATION tackmobile.com
  • 65. git reset use cases • Back that last commit up (git reset HEAD^) • Don’t forget `commit --amend` • Oops, didn’t mean to commit that file • I meant that commit to be on a branch! PRESENTATION tackmobile.com
  • 66. The Take Home • SCM Is Important • No matter what kind of developer you are • Git is fundamentally different from the others • It’s not a database of patches • It’s a history of filesystem snapshots • It gives you freedom to innovate, make mistakes, and collaborate. PRESENTATION tackmobile.com
  • 67. Thank you! #AnDevCon @tackmobile @thillerson http://github.com/thillerson http://slideshare.com/thillerson For the Android Developer • Tony Hillerson • AnDevCon Spring 2012 PRESENTATION tackmobile.com