SlideShare a Scribd company logo
Git
For the Android Developer
AnDevCon 2011 : Tony Hillerson
#AnDevCon #effectiveui
http://www.slideshare.net/thillerson/scm-for-android-developers-using-git
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:
Preliminaries
Getting Git and Getting Set Up
What’s a Git?

 A completely ignorant, childish person with no manners.
                                                               - http://urbandictionary.com




                 Linus Torvalds
                 http://en.wikipedia.org/wiki/Linus_Torvalds
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
Getting Set Up on Mac
• Homebrew - http://mxcl.github.com/homebrew/
• MacPorts - http://www.macports.org/
Getting Set Up on Windows
• msysgit -http://code.google.com/p/msysgit/
• Cygwin - http://www.cygwin.com/
Getting Set Up on Linux
• apt, etc - you probably know the drill
Gooies!
• Git Tower - http://git-tower.com                                                           M
• Brother Bard’s GitX fork -
Mac                            http://brotherbard.com/blog/2010/03/experimental-gitx-fork/
                                                                                             A
                                                                                             C

•     Tortoise Git - http://code.google.com/p/tortoisegit/                                   W
Mac
                                                                                             I
                                                                                             N
Eclipse Integration
• http://www.eclipse.org/egit/
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
Note
• Code may be in backticks: `git <command>`
  • Don’t input the backticks
The Command Line
A Short Sermon
Seven Use Cases
Where Git will Make your Life Easier
Project History
Git will Make your Life Easier
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
Simple Commands
• `git init`- Creates an empty Git repository
• .gitignore - tells git to ignore certain files
• `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`
• `git add -i` Interactive Add
git               git
         or      clone
init


                 git                  86650c185eda50c9f9d58e2fbdf8b7113e5dee54
                         git commit
   changes       add

                 git
                         git commit   6facfd9f34173f4fb024196996e948a87c85eb56
   changes       add

                 git
                         git commit   b02ef5bf190e28ba24eab3ffab6133181cb5b5ef
   changes       add



       ...   ∞
Simple Workflow
.gitignore
• Can be nested deeply
• https://github.com/github/gitignore
  • Use it! Contribute!
Git Log - The Project’s History
• What got committed?
• Commit messages
• Content
• When? Who?
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


       “... 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)
Interactive Add - Building 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
Getting Out of Trouble
Git will Make your Life Easier
Advanced Commands
• blame
• checkout
• commit -a
• reset
• stash
• commit --amend
• revert
git blame
• remember: git help blame
• Who broke the build??? etc...
git checkout, commit -a, reset
• remember: git help reset
• `git commit -a` = commit bypassing `git add`
• `git checkout <filename>` = remove all unstaged changes
• `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

• `git reset --soft` = rollback commit to stage
git stash
• remember: git help stash
• Stash away changes in a safe place
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
git revert
• Commits the reverse of a commit
• The previous commit is still there
• != svn revert
Collaboration
Git will Make your Life Easier
Remotes
• remote add
• push
• clone
• pull
• fetch
Strategies
• Star
• Peer to Peer
• Blessed Repository
• Hierarchical
Committer


              Committer                Committer




                           “The
       Committer          Server”                  Committer




                           Committer




Star
• ssh://user@computer:path/to/repo.git
• http                           Peer

• Gitosis
• Gitolite
                     Peer                Peer




Peer to N Peers
Dictator      ... etc. Maintains a “blessed repository”




            Lieutenant                                                Lieutenant




Developer                Developer              Developer                                      Developer




Hierarchical (Linux model)
Topical Development
Git will Make your Life Easier
Branching
• checkout -b
• merging
• Rebasing
• cherry-pick
How To Think About Branching
• Topic Branches
• Mainline
  • What do you want “master” to mean?
• Branching examples
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
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
Branching
                           git checkout -b add_login_activity




master


Mac
      fb4f5d9   c5083fa



                          add_login_activity


                          Mac

                                9aa8827        fe594ce    ccb6f5e
Branching: Merging

                                                git checkout master

                                                                      git merge add_login_activity

master


Mac                                                                     9aa8827        fe594ce       ccb6f5e
      fb4f5d9   c5083fa           3f43fa3




                      add_login_activity


                      Mac

                            9aa8827         fe594ce        ccb6f5e
Branching: Rebasing
 master

 Mac
       fb4f5d9   c5083fa         3f43fa3



                           add_login_activity


        before             Mac
                            9aa8827             fe594ce           ccb6f5e



master

Mac
      fb4f5d9    c5083fa         3f43fa3



                                                  add_login_activit

        after                                     Mac
                                                        9aa8827        fe594ce   ccb6f5e
        `git rebase master`
Branching: Rebasing
• Better than merging
• Don’t use if you’ve pushed your branch to a remote
  • Git will complain about refs
  • Can override with `git push -force`
• Also available on `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`
Cherry-pick

                 git cherry-pick fe594ce


                                                       A new commit
master                                                with the changes
                                                       from fe594ce

Mac
      fb4f5d9   c5083fa           3f43fa3




                      add_login_activity


                      Mac

                            9aa8827         fe594ce            ccb6f5e
Cherry Picking
• Doesn’t add a reference to the old commit
• Only applies the changes
• Future merges should apply cleanly
Release Management
Git will Make your Life Easier
Tagging
• tag
• push --tags
Tagging

      git tag -a -m"Tagging v1.0" v1.0 c5083fa



master


Mac
      fb4f5d9        c5083fa        3f43fa3




• Both -v1.0 and c5083fa will point to c5083fa
• Push this tag with `git push --tags`
• Can be cryptologically signed
Bug Fixing
Git will Make your Life Easier
Bug Fixing
• blame
• bisect
Bisect
  git bisect start                                                            HEAD
  git bisect bad



         fb4f5d9
       Mac
                     c5083fa   3f43fa3   9aa8827   fe594ce   ccb6f5e        2e531cb



  git bisect good fb4f5d9                 HEAD




         fb4f5d9
       Mac
                     c5083fa   3f43fa3   9aa8827   fe594ce   ccb6f5e        2e531cb



  git bisect good
                                                                       Git tells you
                                                                       this was the
  git bisect good
                                                                       first bad
  git bisect bad                                                       commit
                                                             HEAD




         fb4f5d9
       Mac
                     c5083fa   3f43fa3   9aa8827   fe594ce   ccb6f5e        2e531cb
Open Source Code
Git will Make your Life Easier
Github.com
• Search it!
• Forking
• Pull Requests
Thank you!




Git
For the Android Developer
AnDevCon 2011 : Tony Hillerson
Ad

Recommended

Git For The Android Developer
Git For The Android Developer
Effective
 
Git for Android Developers
Git for Android Developers
Tack Mobile
 
Git training
Git training
Jérémy Gobet
 
Git Educated About Git - 20 Essential Commands
Git Educated About Git - 20 Essential Commands
Jeremy Lindblom
 
Git Introduction
Git Introduction
Gareth Hall
 
Git and Github
Git and Github
Wen-Tien Chang
 
Brief tutorial on Git
Brief tutorial on Git
聖文 鄭
 
Git and git workflow best practice
Git and git workflow best practice
Majid Hosseini
 
Presentacion git
Presentacion git
Ignacio Martín
 
Why You Should Be Using Git
Why You Should Be Using Git
Francisco Vieira
 
Git advanced
Git advanced
Peter Vandenabeele
 
Git essentials
Git essentials
Otto Kekäläinen
 
Starting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
Nick Quaranto
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
tmacwilliam
 
GitBlit plugin for Gerrit Code Review
GitBlit plugin for Gerrit Code Review
Luca Milanesio
 
Getting Started with Git
Getting Started with Git
Rick Umali
 
沒有 GUI 的 Git
沒有 GUI 的 Git
Chia Wei Tsai
 
Git Basics Philips
Git Basics Philips
Ariejan de Vroom
 
Advanced Git
Advanced Git
Sergiu-Ioan Ungur
 
Git'in on Windows
Git'in on Windows
Stacy Vicknair
 
01 git interview questions &amp; answers
01 git interview questions &amp; answers
DeepQuest Software
 
Git internals
Git internals
Haggai Philip Zagury
 
Essential git for developers
Essential git for developers
Adam Culp
 
Flow
Flow
Eugen Martynov
 
Introduction to git, an efficient distributed version control system
Introduction to git, an efficient distributed version control system
AlbanLevy
 
Git'in in 15
Git'in in 15
Stacy Vicknair
 
Grafittis, Lenguaje Urbano
Grafittis, Lenguaje Urbano
nico552
 
NLRB report of the acting general counsel concerning social media cases
NLRB report of the acting general counsel concerning social media cases
Elizabeth Lupfer
 
How To Present
How To Present
Geoff Stilwell
 

More Related Content

What's hot (19)

Presentacion git
Presentacion git
Ignacio Martín
 
Why You Should Be Using Git
Why You Should Be Using Git
Francisco Vieira
 
Git advanced
Git advanced
Peter Vandenabeele
 
Git essentials
Git essentials
Otto Kekäläinen
 
Starting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
Nick Quaranto
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
tmacwilliam
 
GitBlit plugin for Gerrit Code Review
GitBlit plugin for Gerrit Code Review
Luca Milanesio
 
Getting Started with Git
Getting Started with Git
Rick Umali
 
沒有 GUI 的 Git
沒有 GUI 的 Git
Chia Wei Tsai
 
Git Basics Philips
Git Basics Philips
Ariejan de Vroom
 
Advanced Git
Advanced Git
Sergiu-Ioan Ungur
 
Git'in on Windows
Git'in on Windows
Stacy Vicknair
 
01 git interview questions &amp; answers
01 git interview questions &amp; answers
DeepQuest Software
 
Git internals
Git internals
Haggai Philip Zagury
 
Essential git for developers
Essential git for developers
Adam Culp
 
Flow
Flow
Eugen Martynov
 
Introduction to git, an efficient distributed version control system
Introduction to git, an efficient distributed version control system
AlbanLevy
 
Git'in in 15
Git'in in 15
Stacy Vicknair
 
Why You Should Be Using Git
Why You Should Be Using Git
Francisco Vieira
 
Starting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
Nick Quaranto
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
tmacwilliam
 
GitBlit plugin for Gerrit Code Review
GitBlit plugin for Gerrit Code Review
Luca Milanesio
 
Getting Started with Git
Getting Started with Git
Rick Umali
 
01 git interview questions &amp; answers
01 git interview questions &amp; answers
DeepQuest Software
 
Essential git for developers
Essential git for developers
Adam Culp
 
Introduction to git, an efficient distributed version control system
Introduction to git, an efficient distributed version control system
AlbanLevy
 

Viewers also liked (20)

Grafittis, Lenguaje Urbano
Grafittis, Lenguaje Urbano
nico552
 
NLRB report of the acting general counsel concerning social media cases
NLRB report of the acting general counsel concerning social media cases
Elizabeth Lupfer
 
How To Present
How To Present
Geoff Stilwell
 
The Talent Dialogue
The Talent Dialogue
Elizabeth Lupfer
 
Ppt_Felicitacions Nadal
Ppt_Felicitacions Nadal
María Estévez
 
Placing Trust in Employee Engagement by Acas Council
Placing Trust in Employee Engagement by Acas Council
Elizabeth Lupfer
 
PCM
PCM
LEFLOT Jean-Louis
 
Mercer: What's Working Research on Employee Engagement
Mercer: What's Working Research on Employee Engagement
Elizabeth Lupfer
 
Holiday Greetings
Holiday Greetings
Susan Joy Schleef
 
Contact Center Pipeline Drive Culture Improvement
Contact Center Pipeline Drive Culture Improvement
Elizabeth Lupfer
 
Communicationppt
Communicationppt
CarolynOsborne
 
Qualigence Vs Competitors
Qualigence Vs Competitors
Steve Lowisz
 
INRI CRISTO's Biography
INRI CRISTO's Biography
Assinoê Oliveira
 
Top 10 Clues That Your Presentation Is Too Long
Top 10 Clues That Your Presentation Is Too Long
Susan Joy Schleef
 
Social Media In The Workplace
Social Media In The Workplace
Elizabeth Lupfer
 
Vaccine Anticancer
Vaccine Anticancer
Assinoê Oliveira
 
Auto Presentation1
Auto Presentation1
guest0f5fd0
 
Podcasting In The Spanish Classroom
Podcasting In The Spanish Classroom
Jason Noble
 
Universal McCann Wave 2
Universal McCann Wave 2
Elizabeth Lupfer
 
Grafittis, Lenguaje Urbano
Grafittis, Lenguaje Urbano
nico552
 
NLRB report of the acting general counsel concerning social media cases
NLRB report of the acting general counsel concerning social media cases
Elizabeth Lupfer
 
Placing Trust in Employee Engagement by Acas Council
Placing Trust in Employee Engagement by Acas Council
Elizabeth Lupfer
 
Mercer: What's Working Research on Employee Engagement
Mercer: What's Working Research on Employee Engagement
Elizabeth Lupfer
 
Contact Center Pipeline Drive Culture Improvement
Contact Center Pipeline Drive Culture Improvement
Elizabeth Lupfer
 
Qualigence Vs Competitors
Qualigence Vs Competitors
Steve Lowisz
 
Top 10 Clues That Your Presentation Is Too Long
Top 10 Clues That Your Presentation Is Too Long
Susan Joy Schleef
 
Social Media In The Workplace
Social Media In The Workplace
Elizabeth Lupfer
 
Auto Presentation1
Auto Presentation1
guest0f5fd0
 
Podcasting In The Spanish Classroom
Podcasting In The Spanish Classroom
Jason Noble
 
Ad

Similar to SCM for Android Developers Using Git (20)

Git tutorial
Git tutorial
Elli Kanal
 
Git in action
Git in action
Aleksei Kornev
 
Source control management
Source control management
Owen Winkler
 
Git cheat-sheets
Git cheat-sheets
ozone777
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
Forest Mars
 
Git basic stanley hsiao 2010_12_15
Git basic stanley hsiao 2010_12_15
Chen-Han Hsiao
 
Introduction to Git
Introduction to Git
atishgoswami
 
Git One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git training
Git training
adm_exoplatform
 
Git Tech Talk
Git Tech Talk
Chris Johnson
 
Advanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
Git Going With DVCS v1.5.2
Git Going With DVCS v1.5.2
Matthew McCullough
 
Git in Eclipse
Git in Eclipse
Dariusz Łuksza
 
Git 101 for_tarad_dev
Git 101 for_tarad_dev
Somkiat Puisungnoen
 
The git
The git
Leonardo YongUk Kim
 
Formation git
Formation git
Ghariani Tewfik
 
Git in 5 Minutes
Git in 5 Minutes
Robert Dumas
 
M.Mozūras - git
M.Mozūras - git
Agile Lietuva
 
Git Basics at Rails Underground
Git Basics at Rails Underground
Ariejan de Vroom
 
Working with Git
Working with Git
Pete Nicholls
 
Ad

More from Tony Hillerson (11)

Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)
Tony Hillerson
 
Working with Git
Working with Git
Tony Hillerson
 
Dynamic Sound for Android
Dynamic Sound for Android
Tony Hillerson
 
Git for Android Developers
Git for Android Developers
Tony Hillerson
 
Designing an Android App from Idea to Market
Designing an Android App from Idea to Market
Tony Hillerson
 
Rails on HBase
Rails on HBase
Tony Hillerson
 
Flex With Rubyamf
Flex With Rubyamf
Tony Hillerson
 
First Android Experience
First Android Experience
Tony Hillerson
 
iPhone Persistence For Mere Mortals
iPhone Persistence For Mere Mortals
Tony Hillerson
 
Flex Framework Smackdown
Flex Framework Smackdown
Tony Hillerson
 
Flex And Rails
Flex And Rails
Tony Hillerson
 
Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)
Tony Hillerson
 
Dynamic Sound for Android
Dynamic Sound for Android
Tony Hillerson
 
Git for Android Developers
Git for Android Developers
Tony Hillerson
 
Designing an Android App from Idea to Market
Designing an Android App from Idea to Market
Tony Hillerson
 
First Android Experience
First Android Experience
Tony Hillerson
 
iPhone Persistence For Mere Mortals
iPhone Persistence For Mere Mortals
Tony Hillerson
 
Flex Framework Smackdown
Flex Framework Smackdown
Tony Hillerson
 

Recently uploaded (20)

Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 

SCM for Android Developers Using Git

  • 1. Git For the Android Developer AnDevCon 2011 : Tony Hillerson #AnDevCon #effectiveui http://www.slideshare.net/thillerson/scm-for-android-developers-using-git
  • 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:
  • 4. What’s a Git? A completely ignorant, childish person with no manners. - http://urbandictionary.com Linus Torvalds http://en.wikipedia.org/wiki/Linus_Torvalds
  • 5. 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
  • 6. Getting Set Up on Mac • Homebrew - http://mxcl.github.com/homebrew/ • MacPorts - http://www.macports.org/
  • 7. Getting Set Up on Windows • msysgit -http://code.google.com/p/msysgit/ • Cygwin - http://www.cygwin.com/
  • 8. Getting Set Up on Linux • apt, etc - you probably know the drill
  • 9. Gooies! • Git Tower - http://git-tower.com M • Brother Bard’s GitX fork - Mac http://brotherbard.com/blog/2010/03/experimental-gitx-fork/ A C • Tortoise Git - http://code.google.com/p/tortoisegit/ W Mac I N
  • 11. 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
  • 12. Note • Code may be in backticks: `git <command>` • Don’t input the backticks
  • 13. The Command Line A Short Sermon
  • 14. Seven Use Cases Where Git will Make your Life Easier
  • 15. Project History Git will Make your Life Easier
  • 16. 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
  • 17. Simple Commands • `git init`- Creates an empty Git repository • .gitignore - tells git to ignore certain files • `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` • `git add -i` Interactive Add
  • 18. git git or clone init git 86650c185eda50c9f9d58e2fbdf8b7113e5dee54 git commit changes add git git commit 6facfd9f34173f4fb024196996e948a87c85eb56 changes add git git commit b02ef5bf190e28ba24eab3ffab6133181cb5b5ef changes add ... ∞ Simple Workflow
  • 19. .gitignore • Can be nested deeply • https://github.com/github/gitignore • Use it! Contribute!
  • 20. Git Log - The Project’s History • What got committed? • Commit messages • Content • When? Who?
  • 21. 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 “... 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)
  • 22. Interactive Add - Building 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
  • 23. Getting Out of Trouble Git will Make your Life Easier
  • 24. Advanced Commands • blame • checkout • commit -a • reset • stash • commit --amend • revert
  • 25. git blame • remember: git help blame • Who broke the build??? etc...
  • 26. git checkout, commit -a, reset • remember: git help reset • `git commit -a` = commit bypassing `git add` • `git checkout <filename>` = remove all unstaged changes • `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 • `git reset --soft` = rollback commit to stage
  • 27. git stash • remember: git help stash • Stash away changes in a safe place
  • 28. 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
  • 29. git revert • Commits the reverse of a commit • The previous commit is still there • != svn revert
  • 30. Collaboration Git will Make your Life Easier
  • 31. Remotes • remote add • push • clone • pull • fetch
  • 32. Strategies • Star • Peer to Peer • Blessed Repository • Hierarchical
  • 33. Committer Committer Committer “The Committer Server” Committer Committer Star
  • 34. • ssh://user@computer:path/to/repo.git • http Peer • Gitosis • Gitolite Peer Peer Peer to N Peers
  • 35. Dictator ... etc. Maintains a “blessed repository” Lieutenant Lieutenant Developer Developer Developer Developer Hierarchical (Linux model)
  • 36. Topical Development Git will Make your Life Easier
  • 37. Branching • checkout -b • merging • Rebasing • cherry-pick
  • 38. How To Think About Branching • Topic Branches • Mainline • What do you want “master” to mean? • Branching examples
  • 39. 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
  • 40. 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
  • 41. Branching git checkout -b add_login_activity master Mac fb4f5d9 c5083fa add_login_activity Mac 9aa8827 fe594ce ccb6f5e
  • 42. Branching: Merging git checkout master git merge add_login_activity master Mac 9aa8827 fe594ce ccb6f5e fb4f5d9 c5083fa 3f43fa3 add_login_activity Mac 9aa8827 fe594ce ccb6f5e
  • 43. Branching: Rebasing master Mac fb4f5d9 c5083fa 3f43fa3 add_login_activity before Mac 9aa8827 fe594ce ccb6f5e master Mac fb4f5d9 c5083fa 3f43fa3 add_login_activit after Mac 9aa8827 fe594ce ccb6f5e `git rebase master`
  • 44. Branching: Rebasing • Better than merging • Don’t use if you’ve pushed your branch to a remote • Git will complain about refs • Can override with `git push -force` • Also available on `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`
  • 45. Cherry-pick git cherry-pick fe594ce A new commit master with the changes from fe594ce Mac fb4f5d9 c5083fa 3f43fa3 add_login_activity Mac 9aa8827 fe594ce ccb6f5e
  • 46. Cherry Picking • Doesn’t add a reference to the old commit • Only applies the changes • Future merges should apply cleanly
  • 47. Release Management Git will Make your Life Easier
  • 49. Tagging git tag -a -m"Tagging v1.0" v1.0 c5083fa master Mac fb4f5d9 c5083fa 3f43fa3 • Both -v1.0 and c5083fa will point to c5083fa • Push this tag with `git push --tags` • Can be cryptologically signed
  • 50. Bug Fixing Git will Make your Life Easier
  • 52. Bisect git bisect start HEAD git bisect bad fb4f5d9 Mac c5083fa 3f43fa3 9aa8827 fe594ce ccb6f5e 2e531cb git bisect good fb4f5d9 HEAD fb4f5d9 Mac c5083fa 3f43fa3 9aa8827 fe594ce ccb6f5e 2e531cb git bisect good Git tells you this was the git bisect good first bad git bisect bad commit HEAD fb4f5d9 Mac c5083fa 3f43fa3 9aa8827 fe594ce ccb6f5e 2e531cb
  • 53. Open Source Code Git will Make your Life Easier
  • 54. Github.com • Search it! • Forking • Pull Requests
  • 55. Thank you! Git For the Android Developer AnDevCon 2011 : Tony Hillerson