Git and XCode - Nsspain2013

39
Git and XCode Alfonso Alba @aprendegit martes, 17 de septiembre de 13

description

Slide for the presentation "Git and Xcode" given @NSSpain 2013 in Logroño, Spain.

Transcript of Git and XCode - Nsspain2013

Page 1: Git and XCode - Nsspain2013

Git and XCodeAlfonso Alba@aprendegit

martes, 17 de septiembre de 13

Page 2: Git and XCode - Nsspain2013

martes, 17 de septiembre de 13

Page 3: Git and XCode - Nsspain2013

How?

martes, 17 de septiembre de 13

Page 4: Git and XCode - Nsspain2013

Minimum man-hour

martes, 17 de septiembre de 13

Page 5: Git and XCode - Nsspain2013

• If you commit often:

• Your commits will be smaller

• Your history will be more readable

• It will be easier to cherry-pick or revert

martes, 17 de septiembre de 13

Page 6: Git and XCode - Nsspain2013

Commit often

XCode 4 XCode 5

ALT-CMD-C

martes, 17 de septiembre de 13

Page 7: Git and XCode - Nsspain2013

martes, 17 de septiembre de 13

Page 8: Git and XCode - Nsspain2013

• If you do not write good commit messages

martes, 17 de septiembre de 13

Page 9: Git and XCode - Nsspain2013

Write good commit messages

XCode 4 XCode 5

You cannot commit empty messages

martes, 17 de septiembre de 13

Page 10: Git and XCode - Nsspain2013

• If you commit only related changes

• Your history will be more readable

• It will be easier to find bugs

• It will be easier to cherry-pick or revert

martes, 17 de septiembre de 13

Page 11: Git and XCode - Nsspain2013

Commit related changes

You cannot commit chunks

XCode 4 XCode 5

martes, 17 de septiembre de 13

Page 12: Git and XCode - Nsspain2013

• If you use branches

• It will cost you less effort to switch context

• It will be easier to do code review

• You will try new things more often

• It will be easier to refactor

martes, 17 de septiembre de 13

Page 13: Git and XCode - Nsspain2013

Use branches

Have you ever tried to change a branch in XCode?

XCode 4 XCode 5

martes, 17 de septiembre de 13

Page 14: Git and XCode - Nsspain2013

THE Problem:Merging

martes, 17 de septiembre de 13

Page 15: Git and XCode - Nsspain2013

“My” experience with git is:

martes, 17 de septiembre de 13

Page 16: Git and XCode - Nsspain2013

• You will have problems with

• xcuserdata

• xcworspacedata

• Core Data Models

• .xib files

• Story Boards

• Assets

martes, 17 de septiembre de 13

Page 17: Git and XCode - Nsspain2013

How to deal with / mitigate

THE problem

martes, 17 de septiembre de 13

Page 18: Git and XCode - Nsspain2013

• xcuserdata

• Do not include this file in your rempository

• Use a good .gitignore file

• http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects

martes, 17 de septiembre de 13

Page 19: Git and XCode - Nsspain2013

• xcworkspacedata

• ... you will have to resolve conflics manually

martes, 17 de septiembre de 13

Page 20: Git and XCode - Nsspain2013

• Core Data Models

• Create the models on code(Daniel Eggert contribution)

• Use migrations

•Test your models

• Sessions and Workshops during the conference!!

martes, 17 de septiembre de 13

Page 21: Git and XCode - Nsspain2013

• XIB and Story Boards

• ... well, if it was easy our life would be much boring!!

martes, 17 de septiembre de 13

Page 22: Git and XCode - Nsspain2013

Do not use xib files or story boards:

Yes, you will have to write code

martes, 17 de septiembre de 13

Page 23: Git and XCode - Nsspain2013

This is my code, don’t you dare touch it!!

martes, 17 de septiembre de 13

Page 24: Git and XCode - Nsspain2013

• If you want to use Interface Builder

• Split the story boards

• Use xib files instead of story boards

• Agree on a workflow and/or protocol

• Good team comunication

• Use file locking (subversion)

• git checkout --theirs / git checkout --ours

martes, 17 de septiembre de 13

Page 25: Git and XCode - Nsspain2013

DEMO: git checkout-index

martes, 17 de septiembre de 13

Page 26: Git and XCode - Nsspain2013

baboonhttps://github.com/SeyZ/baboon

martes, 17 de septiembre de 13

Page 27: Git and XCode - Nsspain2013

baboon

baboon client

working copy

baboon client

working copy

bare repo

martes, 17 de septiembre de 13

Page 28: Git and XCode - Nsspain2013

Other tools

martes, 17 de septiembre de 13

Page 30: Git and XCode - Nsspain2013

Is git your tool?

martes, 17 de septiembre de 13

Page 31: Git and XCode - Nsspain2013

• Git is not perfect

• BAD for binary files

• No folders

• Guess file renaming

• Too flexible

• Steep learning curve

• No file locking

martes, 17 de septiembre de 13

Page 32: Git and XCode - Nsspain2013

Access Control

martes, 17 de septiembre de 13

Page 33: Git and XCode - Nsspain2013

No history rewrites

martes, 17 de septiembre de 13

Page 34: Git and XCode - Nsspain2013

Undo

martes, 17 de septiembre de 13

Page 35: Git and XCode - Nsspain2013

• Enterprise tools

• Github Enterprise

• Stash

• Sourceforge

• PlasticSCM

martes, 17 de septiembre de 13

Page 36: Git and XCode - Nsspain2013

One more thing...

martes, 17 de septiembre de 13

Page 37: Git and XCode - Nsspain2013

Git is not a backup system

martes, 17 de septiembre de 13

Page 38: Git and XCode - Nsspain2013

Thank you!!

martes, 17 de septiembre de 13

Page 39: Git and XCode - Nsspain2013

[email protected]://www.aprendegit.com

@aprendegit

@aalbagarcia

martes, 17 de septiembre de 13