SlideShare uma empresa Scribd logo
1 de 77
Baixar para ler offline
Git
For the Android Developer
Tony Hillerson, AnDevCon Fall 2013
#AnDevCon @tackmobile @thillerson
About Me
•

@thillerson, +thillerson

•

Developer at Tack Mobile

(tackmobile.com), @tackmobile

•

Android, iOS, and Mobile Web

•

Rails, Node, maybe Elixir (one day)

Presentation

tackmobile.com
Diving Right In
Learning by Doing

Image © Dennis Barnes

http://www.flickr.com/photos/dennisbarnes/2817664242
git
init

or

git
clone

changes

git
add

git commit

86650c185

changes

git
add

git commit

6facfd9f3

changes

git
add

git commit

b02ef5bf1

... ∞

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
What’s a Git?
A completely ignorant, childish person with no
manners. - http://urbandictionary.com

Linus Torvalds
http://en.wikipedia.org/wiki/Linus_Torvalds

Presentation

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!
•

SourceTree (Mac and Windows)

http://sourcetreeapp.com/

•

TortoiseGit (Windows)

http://code.google.com/p/tortoisegit/

Presentation

tackmobile.com
IDE Integration
•

Android Studio

You’re All Set

•

Eclipse

http://www.eclipse.org/egit/

Presentation

tackmobile.com
Reference
•

Git

http://git-scm.com/

•

ProGit

http://progit.org/book/

•

Insider Guide to Github

http://www.pragprog.com/screencasts/vscgithub/insider-guide-to-github

Presentation

tackmobile.com
The Command Line
A Short Sermon

Presentation

tackmobile.com
The Guts of Git
The Little Bits that Make Git Different
What’s With all the Characters?
•

SHA1 Hash e.g.

86650c185eda50c9f9d58e2fbdf8b7113e5dee54

•

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

579a3b1

Presentation

e8d5cf6

tackmobile.com
Trees Give Structure
9899d2c

com/yourcompany/androidapp

b84ed8ed

579a3b1

FooFragment.java

e8d5cf6

BarView.java

3ffb35b

Presentation

MainActivity.java

/anotherpackage

trees can point
to other trees

tackmobile.com
Commits Point to Trees
d414c3e

9899d2c

com/yourcompany/androidapp

“Fixed bug # 42”
b84ed8ed

579a3b1

FooFragment.java

e8d5cf6

BarView.java

3ffb35b

Presentation

MainActivity.java

/anotherpackage

tackmobile.com
Commits Have Parents
090c953

4

“Updated the main activity”

d414c3e

3

“Fixed bug #42”

4493671

2

“Typed awesome code”

c1d1f60

1

“Initial commit”
Presentation

tackmobile.com
Refs Point to Commits
HEAD

090c953

4

“Updated the main activity”

d414c3e

3

“Fixed bug #42”

4493671

2

“Typed awesome code”

c1d1f60

1

“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
Day to Day Git
“What would you say you *do* here?”
Semantic Commits
Make Commits Mean Something

Presentation

tackmobile.com
Semantic Commits
•

Git’s not just a big truck

•

Commits should each mean something

Presentation

tackmobile.com
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
Interactive Add - SourceTree

Presentation

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

Presentation

tackmobile.com
Branching
•

New branch: git checkout -b <name>

•

A branch is a named ref

•

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

Presentation

fe594ce

ccb6f5e

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

fb4f5d9

c5083fa

9aa8827

3f43fa3

fe594ce

ccb6f5e

add_login_activity

9aa8827

Presentation

fe594ce

ccb6f5e

tackmobile.com
Branching: Rebasing
master
fb4f5d9

c5083fa

3f43fa3

add_login_activity

before

9aa8827

fe594ce

ccb6f5e

master
fb4f5d9

c5083fa

3f43fa3

add_login_activity

after
`git rebase master`

Presentation

9aa8827

fe594ce

ccb6f5e

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`

•

… but don’t

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
•

Presentation

`git reset HEAD` and start over with normal
`git pull`

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

Presentation

tackmobile.com
git stash
•

remember: git help stash

•

Stash away changes in a safe place

•

A Workflow:

Stash -> Fix & Commit -> Pop Stash

Presentation

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

Presentation

tackmobile.com
Cherry Pick
•

When you need a commit’s changes

•

But not its history

Presentation

tackmobile.com
Cherry-pick
git cherry-pick fe594ce
A new commit
with the changes
from fe594ce

master

fb4f5d9

c5083fa

3f43fa3

add_login_activity

9aa8827

Presentation

fe594ce

ccb6f5e

tackmobile.com
Whoops!
Lots Of Ways To Fix It

Presentation

tackmobile.com
git checkout
•

`git checkout [filename]`

=

remove unstaged changes

Presentation

tackmobile.com
git revert
•

Commits the reverse of a commit

•

The previous commit is still there

•

!= svn revert

Presentation

tackmobile.com
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
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
git reset
•

`git reset [filename]` = opposite of `git add
[filename]`

•

`git reset HEAD` = same as above - acts on all
tracked 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 [commit]
1. Moves HEAD to [commit]
2. Puts the “popped” contents on the index

Presentation

tackmobile.com
git reset [commit] (“mixed” - default)
1. Moves HEAD to [commit]
2. Puts the “popped” contents on the index
3. Moves the index’s changes to the working tree
4. Clears the index

Presentation

tackmobile.com
git reset --hard [commit] (DESTRUCTIVE!!!)
1. Moves HEAD to [commit]
2. Puts the “popped” contents on the index
3. Moves the index’s changes to the working tree
4. Clears the index
5. Makes the working copy look like the index

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 different
branch!

Presentation

tackmobile.com
Git Flow
A Popular Branching Model

Presentation

tackmobile.com
Git Flow
•

Conventions to follow

•

Tools to help you follow conventions

•

http://nvie.com/posts/a-successful-gitbranching-model/

Presentation

tackmobile.com
Git Flow Conventions: Master Branch
•

The master branch is what is publicly available
now

•

You don’t commit directly to master

Presentation

tackmobile.com
Git Flow Conventions: Develop Branch
•

A branch called “develop” is what will become
the next version

•

Day to day work happens on develop

•

“Integration branch”

Presentation

tackmobile.com
Git Flow Conventions: Feature Branches
•

Long running development go on feature
branches: “feature/foo”

•

Long running: “more than one commit”

•

Can be pushed to the server and shared

•

Branch from develop

Presentation

tackmobile.com
Git Flow Conventions: Hotfixes
•

OMG Problems in Production, create a hotfix:
“hotfix/foo”

•

Branch from master (not develop)

Presentation

tackmobile.com
Git Flow Conventions: Releases
•

When a release is almost ready on develop,
create a release branch: “release/2.0.4”

•

Branch from develop

•

Develop continues on for the next release

•

Small changes to release go on release branch

Presentation

tackmobile.com
Branch Lifecycle
•

Features
•
•

•

Start from develop
Finished and merged to develop

Releases
•

Start from develop

•

Finished and merged to master and develop

Presentation

tackmobile.com
Git Flow in Action: Features

master

develop

feature/somefeature

Presentation

tackmobile.com
Git Flow in Action: Releases

master
release/v1.0

develop

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!
Git for the Android Developer • Tony Hillerson

•

Questions?

•

We’re Hiring! careers@tackmobile.com
•

Excellent Team

•

Awesome Projects

•

Great Office

Mais conteúdo relacionado

Mais procurados

Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git聖文 鄭
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategiesjstack
 
GitLab 8.5 Highlights and Step-by-step tutorial
GitLab 8.5 Highlights and Step-by-step tutorialGitLab 8.5 Highlights and Step-by-step tutorial
GitLab 8.5 Highlights and Step-by-step tutorialHeather McNamee
 
Bringing Pull Request to Gerrit
Bringing Pull Request to GerritBringing Pull Request to Gerrit
Bringing Pull Request to GerritEryk Szymanski
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
GitLab 8.6 - Release Webcast
GitLab 8.6 - Release Webcast GitLab 8.6 - Release Webcast
GitLab 8.6 - Release Webcast GitLab, Inc
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubNick Quaranto
 
Git workflows
Git workflowsGit workflows
Git workflowsXpand IT
 
Git workflow in agile development
Git workflow in agile developmentGit workflow in agile development
Git workflow in agile developmentZack Siri
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developersmpvanwinkle
 
Enterprise git
Enterprise gitEnterprise git
Enterprise gitPedro Melo
 
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro WorkshopOpen Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro WorkshopWong Hoi Sing Edison
 

Mais procurados (20)

Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git sourcecontrolpreso
Git sourcecontrolpresoGit sourcecontrolpreso
Git sourcecontrolpreso
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Flow
FlowFlow
Flow
 
Git Pull Requests
Git Pull RequestsGit Pull Requests
Git Pull Requests
 
GitLab 8.5 Highlights and Step-by-step tutorial
GitLab 8.5 Highlights and Step-by-step tutorialGitLab 8.5 Highlights and Step-by-step tutorial
GitLab 8.5 Highlights and Step-by-step tutorial
 
Bringing Pull Request to Gerrit
Bringing Pull Request to GerritBringing Pull Request to Gerrit
Bringing Pull Request to Gerrit
 
Git'in in 15
Git'in in 15Git'in in 15
Git'in in 15
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git
GitGit
Git
 
GitLab 8.6 - Release Webcast
GitLab 8.6 - Release Webcast GitLab 8.6 - Release Webcast
GitLab 8.6 - Release Webcast
 
Open Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git HubOpen Source Collaboration With Git And Git Hub
Open Source Collaboration With Git And Git Hub
 
Git'in on Windows
Git'in on WindowsGit'in on Windows
Git'in on Windows
 
Git workflows
Git workflowsGit workflows
Git workflows
 
Git workflow in agile development
Git workflow in agile developmentGit workflow in agile development
Git workflow in agile development
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developers
 
Enterprise git
Enterprise gitEnterprise git
Enterprise git
 
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro WorkshopOpen Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
 

Destaque

Social Media In The Workplace
Social Media In The WorkplaceSocial Media In The Workplace
Social Media In The WorkplaceElizabeth Lupfer
 
六合彩,香港六合彩 » SlideShare
六合彩,香港六合彩 » SlideShare六合彩,香港六合彩 » SlideShare
六合彩,香港六合彩 » SlideShareaxluwjc
 
A Balanced Perspective - How to Recruit a Multigenerational Workforce
A Balanced Perspective - How to Recruit a Multigenerational WorkforceA Balanced Perspective - How to Recruit a Multigenerational Workforce
A Balanced Perspective - How to Recruit a Multigenerational WorkforceSteve Lowisz
 
SCM for Android Developers Using Git
SCM for Android Developers Using GitSCM for Android Developers Using Git
SCM for Android Developers Using GitTony Hillerson
 
Placing Trust in Employee Engagement by Acas Council
Placing Trust in Employee Engagement by Acas CouncilPlacing Trust in Employee Engagement by Acas Council
Placing Trust in Employee Engagement by Acas CouncilElizabeth Lupfer
 
Date Of Infamy
Date Of InfamyDate Of Infamy
Date Of InfamyTobyCJ08
 
Information Extraction and Linked Data Cloud
Information Extraction and Linked Data CloudInformation Extraction and Linked Data Cloud
Information Extraction and Linked Data CloudDhaval Thakker
 
MRV Folder Fortune / Fortaleza - CE
MRV Folder Fortune / Fortaleza - CEMRV Folder Fortune / Fortaleza - CE
MRV Folder Fortune / Fortaleza - CEMRV Engenharia
 
Let's Talk About Social Networking
Let's Talk About Social NetworkingLet's Talk About Social Networking
Let's Talk About Social NetworkingSteve Lowisz
 
라이프로깅, 유행인가 본능인가?
라이프로깅, 유행인가 본능인가?라이프로깅, 유행인가 본능인가?
라이프로깅, 유행인가 본능인가?Pengdo .
 
春秋戰國時期的社會經濟和社會變革
春秋戰國時期的社會經濟和社會變革春秋戰國時期的社會經濟和社會變革
春秋戰國時期的社會經濟和社會變革y53102
 
MUC295 LEC1b Job Search 101
MUC295 LEC1b Job Search 101MUC295 LEC1b Job Search 101
MUC295 LEC1b Job Search 101MUC295
 
春秋戰國時期的社會經濟和社會變革
春秋戰國時期的社會經濟和社會變革春秋戰國時期的社會經濟和社會變革
春秋戰國時期的社會經濟和社會變革y53102
 
MUC295 LEC2 Goal Setting
MUC295 LEC2 Goal SettingMUC295 LEC2 Goal Setting
MUC295 LEC2 Goal SettingMUC295
 
5 principles for excellent presentations
5 principles for excellent presentations5 principles for excellent presentations
5 principles for excellent presentationsMatt Scott
 

Destaque (20)

Social Media In The Workplace
Social Media In The WorkplaceSocial Media In The Workplace
Social Media In The Workplace
 
六合彩,香港六合彩 » SlideShare
六合彩,香港六合彩 » SlideShare六合彩,香港六合彩 » SlideShare
六合彩,香港六合彩 » SlideShare
 
A Balanced Perspective - How to Recruit a Multigenerational Workforce
A Balanced Perspective - How to Recruit a Multigenerational WorkforceA Balanced Perspective - How to Recruit a Multigenerational Workforce
A Balanced Perspective - How to Recruit a Multigenerational Workforce
 
SCM for Android Developers Using Git
SCM for Android Developers Using GitSCM for Android Developers Using Git
SCM for Android Developers Using Git
 
Placing Trust in Employee Engagement by Acas Council
Placing Trust in Employee Engagement by Acas CouncilPlacing Trust in Employee Engagement by Acas Council
Placing Trust in Employee Engagement by Acas Council
 
Related rates
Related ratesRelated rates
Related rates
 
Date Of Infamy
Date Of InfamyDate Of Infamy
Date Of Infamy
 
Information Extraction and Linked Data Cloud
Information Extraction and Linked Data CloudInformation Extraction and Linked Data Cloud
Information Extraction and Linked Data Cloud
 
Diapo
DiapoDiapo
Diapo
 
MRV Folder Fortune / Fortaleza - CE
MRV Folder Fortune / Fortaleza - CEMRV Folder Fortune / Fortaleza - CE
MRV Folder Fortune / Fortaleza - CE
 
Prosessrapport
ProsessrapportProsessrapport
Prosessrapport
 
Let's Talk About Social Networking
Let's Talk About Social NetworkingLet's Talk About Social Networking
Let's Talk About Social Networking
 
라이프로깅, 유행인가 본능인가?
라이프로깅, 유행인가 본능인가?라이프로깅, 유행인가 본능인가?
라이프로깅, 유행인가 본능인가?
 
春秋戰國時期的社會經濟和社會變革
春秋戰國時期的社會經濟和社會變革春秋戰國時期的社會經濟和社會變革
春秋戰國時期的社會經濟和社會變革
 
Ppt_Felicitacions Nadal
Ppt_Felicitacions NadalPpt_Felicitacions Nadal
Ppt_Felicitacions Nadal
 
MUC295 LEC1b Job Search 101
MUC295 LEC1b Job Search 101MUC295 LEC1b Job Search 101
MUC295 LEC1b Job Search 101
 
春秋戰國時期的社會經濟和社會變革
春秋戰國時期的社會經濟和社會變革春秋戰國時期的社會經濟和社會變革
春秋戰國時期的社會經濟和社會變革
 
MUC295 LEC2 Goal Setting
MUC295 LEC2 Goal SettingMUC295 LEC2 Goal Setting
MUC295 LEC2 Goal Setting
 
Flex And Rails
Flex And RailsFlex And Rails
Flex And Rails
 
5 principles for excellent presentations
5 principles for excellent presentations5 principles for excellent presentations
5 principles for excellent presentations
 

Semelhante a Git for Android Developers

Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android DevelopersTack Mobile
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android DeveloperEffective
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android DeveloperEffectiveUI
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015mwrather
 
Git talk from Open 2011 conference in Israel
Git talk from Open 2011 conference in IsraelGit talk from Open 2011 conference in Israel
Git talk from Open 2011 conference in IsraelReuven Lerner
 
Front Page of Hacker News with GitLab Pages
Front Page of Hacker News with GitLab PagesFront Page of Hacker News with GitLab Pages
Front Page of Hacker News with GitLab PagesWill Hall
 
Git, YouTrack and TeamCity - DDDSydney 2011
Git, YouTrack and TeamCity - DDDSydney 2011Git, YouTrack and TeamCity - DDDSydney 2011
Git, YouTrack and TeamCity - DDDSydney 2011thinkddd
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Bosstmacwilliam
 
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)Mark Hamstra
 
Git Merge, Resets and Branches
Git Merge, Resets and BranchesGit Merge, Resets and Branches
Git Merge, Resets and BranchesVictor Pudelski
 
[artifactconf] Github for People Who Don't Code
[artifactconf] Github for People Who Don't Code[artifactconf] Github for People Who Don't Code
[artifactconf] Github for People Who Don't CodeChristopher Schmitt
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitRick Umali
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 

Semelhante a Git for Android Developers (20)

Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android Developers
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 
Git for the Android Developer
Git for the Android DeveloperGit for the Android Developer
Git for the Android Developer
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git talk from Open 2011 conference in Israel
Git talk from Open 2011 conference in IsraelGit talk from Open 2011 conference in Israel
Git talk from Open 2011 conference in Israel
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
 
Front Page of Hacker News with GitLab Pages
Front Page of Hacker News with GitLab PagesFront Page of Hacker News with GitLab Pages
Front Page of Hacker News with GitLab Pages
 
Git, YouTrack and TeamCity - DDDSydney 2011
Git, YouTrack and TeamCity - DDDSydney 2011Git, YouTrack and TeamCity - DDDSydney 2011
Git, YouTrack and TeamCity - DDDSydney 2011
 
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a BossGit Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
 
3 Git
3 Git3 Git
3 Git
 
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
Dev, Staging & Production Workflow with Gitify (at MODXpo 2015 in Munich)
 
Git Merge, Resets and Branches
Git Merge, Resets and BranchesGit Merge, Resets and Branches
Git Merge, Resets and Branches
 
Talk to git
Talk to gitTalk to git
Talk to git
 
Intro to Git & GitHub
Intro to Git & GitHubIntro to Git & GitHub
Intro to Git & GitHub
 
[artifactconf] Github for People Who Don't Code
[artifactconf] Github for People Who Don't Code[artifactconf] Github for People Who Don't Code
[artifactconf] Github for People Who Don't Code
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Ultimate Git Workflow - Seoul 2015
Ultimate Git Workflow - Seoul 2015Ultimate Git Workflow - Seoul 2015
Ultimate Git Workflow - Seoul 2015
 

Mais de Tony Hillerson

Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)Tony Hillerson
 
Dynamic Sound for Android
Dynamic Sound for AndroidDynamic Sound for Android
Dynamic Sound for AndroidTony Hillerson
 
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 MarketTony Hillerson
 
First Android Experience
First Android ExperienceFirst Android Experience
First Android ExperienceTony Hillerson
 
iPhone Persistence For Mere Mortals
iPhone Persistence For Mere MortalsiPhone Persistence For Mere Mortals
iPhone Persistence For Mere MortalsTony Hillerson
 
Flex Framework Smackdown
Flex Framework SmackdownFlex Framework Smackdown
Flex Framework SmackdownTony Hillerson
 

Mais de Tony Hillerson (8)

Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)
 
Dynamic Sound for Android
Dynamic Sound for AndroidDynamic Sound for Android
Dynamic Sound 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
 
Rails on HBase
Rails on HBaseRails on HBase
Rails on HBase
 
Flex With Rubyamf
Flex With RubyamfFlex With Rubyamf
Flex With Rubyamf
 
First Android Experience
First Android ExperienceFirst Android Experience
First Android Experience
 
iPhone Persistence For Mere Mortals
iPhone Persistence For Mere MortalsiPhone Persistence For Mere Mortals
iPhone Persistence For Mere Mortals
 
Flex Framework Smackdown
Flex Framework SmackdownFlex Framework Smackdown
Flex Framework Smackdown
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
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
 
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
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
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
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
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
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
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
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
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
 
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
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
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
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
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
 
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?
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
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
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Git for Android Developers

  • 1. Git For the Android Developer Tony Hillerson, AnDevCon Fall 2013 #AnDevCon @tackmobile @thillerson
  • 2. About Me • @thillerson, +thillerson • Developer at Tack Mobile
 (tackmobile.com), @tackmobile • Android, iOS, and Mobile Web • Rails, Node, maybe Elixir (one day) Presentation tackmobile.com
  • 3. Diving Right In Learning by Doing Image © Dennis Barnes
 http://www.flickr.com/photos/dennisbarnes/2817664242
  • 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
  • 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
  • 12. What’s a Git? A completely ignorant, childish person with no manners. - http://urbandictionary.com Linus Torvalds http://en.wikipedia.org/wiki/Linus_Torvalds Presentation 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! • SourceTree (Mac and Windows)
 http://sourcetreeapp.com/ • TortoiseGit (Windows)
 http://code.google.com/p/tortoisegit/ Presentation tackmobile.com
  • 18. IDE Integration • Android Studio
 You’re All Set • Eclipse
 http://www.eclipse.org/egit/ Presentation tackmobile.com
  • 19. Reference • Git
 http://git-scm.com/ • ProGit
 http://progit.org/book/ • Insider Guide to Github
 http://www.pragprog.com/screencasts/vscgithub/insider-guide-to-github Presentation tackmobile.com
  • 20. The Command Line A Short Sermon Presentation tackmobile.com
  • 21. The Guts of Git The Little Bits that Make Git Different
  • 22. What’s With all the Characters? • SHA1 Hash e.g.
 86650c185eda50c9f9d58e2fbdf8b7113e5dee54 • 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
  • 31. Commits Point to Trees d414c3e 9899d2c com/yourcompany/androidapp “Fixed bug # 42” b84ed8ed 579a3b1 FooFragment.java e8d5cf6 BarView.java 3ffb35b Presentation MainActivity.java /anotherpackage tackmobile.com
  • 32. Commits Have Parents 090c953 4 “Updated the main activity” d414c3e 3 “Fixed bug #42” 4493671 2 “Typed awesome code” c1d1f60 1 “Initial commit” Presentation tackmobile.com
  • 33. Refs Point to Commits HEAD 090c953 4 “Updated the main activity” d414c3e 3 “Fixed bug #42” 4493671 2 “Typed awesome code” c1d1f60 1 “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. Day to Day Git “What would you say you *do* here?”
  • 37. Semantic Commits Make Commits Mean Something Presentation tackmobile.com
  • 38. Semantic Commits • Git’s not just a big truck • Commits should each mean something Presentation tackmobile.com
  • 39. 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
  • 40. Interactive Add - SourceTree Presentation tackmobile.com
  • 41. Branching Like Hitting Save Before You Fight the Level Boss Presentation tackmobile.com
  • 42. Branching • New branch: git checkout -b <name> • A branch is a named ref • merging • rebasing Presentation tackmobile.com
  • 43. How To Think About Branching • Mainline • What do you want “master” to mean? • Topic Branches • Branching examples Presentation tackmobile.com
  • 44. 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
  • 45. 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
  • 46. Branching git checkout -b add_login_activity master fb4f5d9 c5083fa add_login_activity 9aa8827 Presentation fe594ce ccb6f5e tackmobile.com
  • 47. Branching: Merging git checkout master git merge add_login_activity master fb4f5d9 c5083fa 9aa8827 3f43fa3 fe594ce ccb6f5e add_login_activity 9aa8827 Presentation fe594ce ccb6f5e tackmobile.com
  • 49. 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` • … but don’t Presentation tackmobile.com
  • 50. Git Pull --rebase • Also available: `git pull --rebase` • Helpful for avoiding merge commits • May cause problems if git can’t automatically merge • Presentation `git reset HEAD` and start over with normal `git pull` tackmobile.com
  • 51. Git Stash Like a Little Repo In Your Repo Presentation tackmobile.com
  • 52. git stash • remember: git help stash • Stash away changes in a safe place • A Workflow:
 Stash -> Fix & Commit -> Pop Stash Presentation tackmobile.com
  • 53. Cherry Pick I’ll Take One Of Those... And One Of Those... Presentation tackmobile.com
  • 54. Cherry Pick • When you need a commit’s changes • But not its history Presentation tackmobile.com
  • 55. Cherry-pick git cherry-pick fe594ce A new commit with the changes from fe594ce master fb4f5d9 c5083fa 3f43fa3 add_login_activity 9aa8827 Presentation fe594ce ccb6f5e tackmobile.com
  • 56. Whoops! Lots Of Ways To Fix It Presentation tackmobile.com
  • 57. git checkout • `git checkout [filename]`
 =
 remove unstaged changes Presentation tackmobile.com
  • 58. git revert • Commits the reverse of a commit • The previous commit is still there • != svn revert Presentation tackmobile.com
  • 59. 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
  • 60. 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
  • 61. git reset • `git reset [filename]` = opposite of `git add [filename]` • `git reset HEAD` = same as above - acts on all tracked 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 [commit] 1. Moves HEAD to [commit] 2. Puts the “popped” contents on the index Presentation tackmobile.com
  • 63. git reset [commit] (“mixed” - default) 1. Moves HEAD to [commit] 2. Puts the “popped” contents on the index 3. Moves the index’s changes to the working tree 4. Clears the index Presentation tackmobile.com
  • 64. git reset --hard [commit] (DESTRUCTIVE!!!) 1. Moves HEAD to [commit] 2. Puts the “popped” contents on the index 3. Moves the index’s changes to the working tree 4. Clears the index 5. Makes the working copy look like the index 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 different branch! Presentation tackmobile.com
  • 66. Git Flow A Popular Branching Model Presentation tackmobile.com
  • 67. Git Flow • Conventions to follow • Tools to help you follow conventions • http://nvie.com/posts/a-successful-gitbranching-model/ Presentation tackmobile.com
  • 68. Git Flow Conventions: Master Branch • The master branch is what is publicly available now • You don’t commit directly to master Presentation tackmobile.com
  • 69. Git Flow Conventions: Develop Branch • A branch called “develop” is what will become the next version • Day to day work happens on develop • “Integration branch” Presentation tackmobile.com
  • 70. Git Flow Conventions: Feature Branches • Long running development go on feature branches: “feature/foo” • Long running: “more than one commit” • Can be pushed to the server and shared • Branch from develop Presentation tackmobile.com
  • 71. Git Flow Conventions: Hotfixes • OMG Problems in Production, create a hotfix: “hotfix/foo” • Branch from master (not develop) Presentation tackmobile.com
  • 72. Git Flow Conventions: Releases • When a release is almost ready on develop, create a release branch: “release/2.0.4” • Branch from develop • Develop continues on for the next release • Small changes to release go on release branch Presentation tackmobile.com
  • 73. Branch Lifecycle • Features • • • Start from develop Finished and merged to develop Releases • Start from develop • Finished and merged to master and develop Presentation tackmobile.com
  • 74. Git Flow in Action: Features master develop feature/somefeature Presentation tackmobile.com
  • 75. Git Flow in Action: Releases master release/v1.0 develop Presentation tackmobile.com
  • 76. 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
  • 77. Thank you! Git for the Android Developer • Tony Hillerson • Questions? • We’re Hiring! careers@tackmobile.com • Excellent Team • Awesome Projects • Great Office