0:00:00Hello and welcome to Developing Perspective. Developing Perspective is a podcast discussing
0:00:04news of note in iOS development, Apple, and the like. I'm your host, David Smith. I'm
0:00:09an independent iOS and Mac developer based in Herne, Virginia. This is show number 94,
0:00:13and today is Thursday, November 8th. Developing Perspective is never longer than 15 minutes,
0:00:18so let's get started.
0:00:19All right, after the long arc I did on Check the Weather, I'm going to be switching up
0:00:24gears a little bit on Developing Perspective and probably going into at least a couple
0:00:28of weeks of, I guess you could call it kind of Q&A. And so if you have any questions or
0:00:33comments or thoughts that you want me to sort of expand upon for 15 minutes, just let me
0:00:38know on Twitter. I'm _DavidSmith there, or on AppNet, I'm DavidSmith, without the underscore.
0:00:44But generally speaking, I just kind of, I thought it'd be interesting to kind of just
0:00:47walk through focus topics for the next couple of weeks while I kind of think about what
0:00:51I want to do next for a big arc or if I want to do a big arc or whatever. So anyway, so
0:00:56So this question that I'm going to talk about today comes from Brad Allen, and he was asking
0:01:02all about Git, version control, and how I use GitHub.
0:01:06And it seemed like a pretty good place to start.
0:01:08Version control is a pretty fundamental topic for developers and for development in general.
0:01:12So first I'm going to back up a little bit before I start talking about Git or GitHub
0:01:16and just talk about version control and what I think it's useful for and what it is and
0:01:21what it isn't.
0:01:23So for me, version control has two primary purposes.
0:01:27One of them is to create an anthology or a collection of all of the code I've ever written
0:01:36that worked.
0:01:38And maybe didn't work, but specifically it's all the code I've ever written that worked.
0:01:42That's what I really want my version control system to be for me.
0:01:46And what I say that is so that I can go back in time, I can pull out little fragments or
0:01:51or little functions or things I've written or things I've done in the past, and I can
0:01:55apply them to my current problem.
0:01:57Typically, in my experience, if you have an existing solution to a problem, it's often
0:02:02better to adapt that to a new problem or a similar problem than it is to entirely reinvent
0:02:08the wheel every time.
0:02:11Source control is great for that because it lets you keep track of not only what the current
0:02:17snapshot at the head of your source control system is, but also all the previous things
0:02:21you've had. And I've often encountered things where I'll go back in time and be like, "Oh,
0:02:25what was that thing I used to do before I did this? Now, whatever." You can kind of
0:02:30go back in time and reach in and grab it. Or, often what I'll end up doing is it allows
0:02:34me to head down a path, kind of capture a vaguely working solution, and then kind of
0:02:40jump over to the actual, like say, my master branch in Git, and I can cherry pick little
0:02:45parts of that into my main code branch. But it's really just about having this anthology
0:02:50of all the stuff I've ever done.
0:02:55That's what version control is important for.
0:02:57Version control for me is not a backup system.
0:02:59It's not something I'm doing in that way.
0:03:02It's not really a--
0:03:05I don't use it as a collaboration system,
0:03:06though obviously many, many, many people do,
0:03:08and most of you who listen to this podcast probably do as well.
0:03:10But I just happen to be a one-man shop,
0:03:13so it's not really useful for collaboration for me in that way.
0:03:15But it is very useful for collaboration.
0:03:15I'll talk about that a little bit when I talk about GitHub.
0:03:18And the second thing it is, is it's incredibly helpful
0:03:20to be able to have repeatable snapshots of code bases.
0:03:25And what I mean by that is, so if I-- right now, I think--
0:03:28let's say check the weather.
0:03:29Version 1.2 is the current App Store version.
0:03:33However, I have version 1.3 already submitted
0:03:35to the App Store.
0:03:36And I have a few even bug fixes beyond that
0:03:39that I've been testing and doing as I've been going along.
0:03:42That's just kind of the development process,
0:03:44especially with Apple where you're kind of,
0:03:49you make a snapshot, you submit it to the App Store,
0:03:51and then you keep moving potentially up to a week or two
0:03:54of changes.
0:03:58And so what is very helpful though is that I can go back
0:03:59and pull up exactly what it was I submitted,
0:04:03I pull up the tag or the commit that I know
0:04:06that I submitted on, and I can recreate something.
0:04:08So even if I get a help desk request from somebody now
0:04:10who says, "I'm having this problem,
0:04:09It's very reproducible, but it only happens on version 1.1.
0:04:13I can go and find version 1.1 inside of my version control system rather than having
0:04:18to do have some kind of clunky making zip files of my source tree or something and archiving
0:04:23them that way.
0:04:24So those are the two things that I really want my version control to do.
0:04:27I want it to have an anthology of all my working code, and I want to have the ability to reproduce
0:04:34particular snapshots in time.
0:04:36That's really it.
0:04:37And exactly what you do, which system you use to do that, really doesn't matter.
0:04:42I mean, I've used, let's see, I started off using CVS back in the day, then I used SVN,
0:04:47and now I use Git, and I've played around with a few of the others, like, was it SourceSafe, Perforce,
0:04:54there's all kinds of these other little version control systems, many of them are
0:05:02I come with big enterprise-y systems,
0:05:07rather than more general or open-source style.
0:05:11And right now I use Git.
0:05:15And I use Git almost exclusively
0:05:16because it's the lingua franca
0:05:18for the development community.
0:05:21And by that I mean, I don't really care.
0:05:24Git does some crazy stuff that I'm sure I could use,
0:05:27but like I said, I'm an independent.
0:05:29I don't need all of the really complicated
0:05:29distributed branching and all the stuff that you can do
0:05:34that is really helpful when you're working on a large team,
0:05:37it's just me.
0:05:41I use Git because everyone else seems to use Git.
0:05:42And so I want to be skilled with it
0:05:45so that I can interact well with other people
0:05:47who post code online or in other different places,
0:05:49and I want to be able to speak that language.
0:05:52It's the most popular one, so I went with it.
0:05:54Git is pretty solid though.
0:05:59I'm not using it kind of reluctantly.
0:06:01It's definitely grown on me.
0:06:03It took a while to wrap my head around it
0:06:05from when I came from an SVN background.
0:06:07The things I like most about Git is that it is distributed.
0:06:10The biggest part of that is that you can do
0:06:14non-connected commits.
0:06:17It's just something that at first I didn't think
0:06:19would make that much of a difference.
0:06:21My server's almost always available,
0:06:20Often I've even run SVN servers locally,
0:06:25so my server's always available.
0:06:29But the fact that you're not tied to a particular,
0:06:31you can completely reproduce a Git repository
0:06:36just by copying its directory.
0:06:39And then you can take that and put it somewhere else
0:06:41just has been really, really helpful
0:06:44in a lot of situations.
0:06:46I can create a copy of my,
0:06:46to take a repository, put it on a thumb drive,
0:06:51go on a trip.
0:06:55I have all of the history that is associated with that repository
0:06:57in that directory.
0:07:01I don't need something else that I'm connecting to.
0:07:02And also, a bigger part of that, I think,
0:07:05is that the latency is zero, which makes it really fast,
0:07:07because I'm not interacting with the server all the time,
0:07:11or even on a local server.
0:07:14It's still not quite as fast as doing direct file access.
0:07:13I think it's also just built to be really fast.
0:07:18So those are the things that I really like about it.
0:07:20I think I don't particularly like some of the,
0:07:23I'm not a huge fan of the two-phase commit.
0:07:27I've gotten used to it, and I'm fine.
0:07:29But my development philosophy tends to be
0:07:31I'm always stage all commit, so it always feels kind of redundant
0:07:34that I have to stage all my files and then commit them.
0:07:37I know why you do that, and it makes sense,
0:07:40but not really for my workflow.
0:07:39And I don't really like that Git has--
0:07:44sometimes I feel like Git is a little too dangerous,
0:07:48or too freeform.
0:07:50And this speaks more to times when I've worked on larger teams
0:07:52where because you can do anything with Git,
0:07:55it creates a couple of situations.
0:07:58One, people can go round and round and round about how we're going to structure our Git flow.
0:08:00You know, Git flow is even a philosophy, or I'm going to organize it.
0:08:06So we have this branch for this, and this branch for this.
0:08:07and I'm going to move merge from this to this.
0:08:09Oh, we have a merge conflict.
0:08:10Let me rebase that with all this crazy stuff
0:08:13that people can end up doing that just isn't really
0:08:16productive.
0:08:16You can create lots and lots of busy work
0:08:18that feels very productive using Git because it's so unstructured
0:08:22and you can do anything.
0:08:24The ability to do anything is often the most dangerous thing
0:08:27in most things in technology.
0:08:30Having a little bit of structure I think would be nice.
0:08:32You can easily enforce that on yourself.
0:08:35For me, the vast majority of my work,
0:08:40I have a master branch that's code I expect to ship.
0:08:42I have branches that is code I'm not sure
0:08:45if I'm going to ship.
0:08:47And then I push that off all,
0:08:49I only really push master onto my main repository repository.
0:08:51But yeah, that's Git at a high level.
0:08:57Git is pretty straightforward in terms of its operation.
0:09:00You get a knit to create a repository.
0:09:02you git add to say that a file should
0:09:04be added to the next commit.
0:09:06You say git commit to commit that file,
0:09:08and then now you've made a snapshot of that current
0:09:11or of the stage files at that point in the directory.
0:09:15And you can branch, git branch, and that
0:09:17creates an alternative fork of your code path
0:09:21that you can develop, download, and commit to,
0:09:23and then you can ultimately git merge to put that back in.
0:09:26It's fairly straightforward.
0:09:27It does all the obvious things.
0:09:28It doesn't do that much that's particularly unique.
0:09:31It does something better than others. Some people say Mercurial is much better.
0:09:35I don't really know or particularly care. Like I said, I use Git not because
0:09:39of its functionality, but because everyone uses it and it does
0:09:43a good enough job that that works fine for me.
0:09:47And so I'm going to talk a little bit about GitHub and what it did. And I think it's kind of a remarkable
0:09:51thing that GitHub kind of solved this problem that I think a lot of people had.
0:09:55And I don't think its success is strictly tied to the fact that they used Git.
0:09:59It just so happened that they used Git and it became very popular in the Rails community,
0:10:03and when GitHub was founded, that was important.
0:10:06But GitHub allows for people to share code very, very easily, to fork and sort of alter
0:10:14it and to kind of have this very efficient open source process that is really very useful.
0:10:21I mean, GitHub is a great resource, and I find I use it mostly for just looking for
0:10:27looking for inspiration, looking for people who've solved the same problems that I've had,
0:10:31and looking at how they did it, or getting some help there.
0:10:36Something like SNEC Overflow is really useful for if you have a question or something very specific.
0:10:40But often what I'm interested in is I'll go and just look at how other people write,
0:10:46especially people who open source code, who the developer is someone I respect, someone who I admire.
0:10:51I love just looking through it.
0:10:56couple days, the Pocket SDK was released, which is some work that Steve Stresa has done.
0:11:02And it was just fascinating to go and look at the way it was structured, and it's really
0:11:05kind of clever and well put together and thoughtfully designed. And that's good for inspiration.
0:11:10And GitHub, I think, is just a great tool for that. It's a great way to kind of put
0:11:14code out there and let people easily pull it down, work on it, change it if they want,
0:11:19and so on. It's not perfect, but I think it does a great job at that. I think GitHub is
0:11:24For collaboration purposes, I've never really gotten into all the crazy stuff you can do,
0:11:29that some organizations will do.
0:11:33You can do milestones and issues and all kinds of stuff like that.
0:11:35Primarily, I just use it for open source stuff.
0:11:39And all my own stuff I actually don't even use at GitHub.
0:11:42All my own stuff I hosted Bitbucket.
0:11:45And I hosted Bitbucket because they have a much better plan for the independent,
0:11:48for someone like me, where they charge based on a number of users,
0:11:52rather than a number of repositories, which is always kind of cumbersome and annoying
0:11:56for me at GitHub.
0:11:58Because I have many dozen repositories.
0:12:01If you've been listening to the show for any length of time, you know that I have a bit
0:12:07of a problem with starting new projects and thinking about things and creating new products
0:12:10and shipping new products.
0:12:12And so I tend to have lots and lots of our code repositories.
0:12:14I think at some point I was paying GitHub for that.
0:12:18I was paying essentially their max rate, which isn't a crazy amount of money.
0:12:23I think I was $50, $60 a month.
0:12:25But still, it wasn't really needed.
0:12:27For Bitbucket, my purposes are much, much less expensive, if anything.
0:12:30I'm not sure.
0:12:31I may even still be in the free plan, even.
0:12:34It's a much better fit for a small developer, for somebody who is just trying to...
0:12:38It's really just kind of an archive for me in a way that I can pull down my code from
0:12:42somewhere else if I need to.
0:12:44But that's kind of what I do for source control.
0:12:48A couple of resources I'd say is definitely
0:12:51go to look at Pro Git, which is an online free book.
0:12:55I believe that you can also buy the book.
0:12:57But it's a great little book if you are learning Git
0:13:01and kind of not really sure how to work your way around
0:13:03or you're trying to solve a specific problem.
0:13:05You're kind of getting into what's the difference between a rebase
0:13:08and a merge.
0:13:09It's a great book for that.
0:13:10I'll have a link in the show notes to it.
0:13:12But otherwise, it's the kind of thing you just play with.
0:13:15And you just want to learn some of the patterns
0:13:17that you want to get good at.
0:13:19And of course, I would be remiss on an iOS development podcast
0:13:23talking about source control to not mention
0:13:25that there are a lot of files that you'll
0:13:28interact with in an Xcode project that do not merge well.
0:13:32And these are nibs, and these are the Xcode project file.
0:13:37And these files are essentially unmergeable.
0:13:41Project files are slightly mergeable, and nibs are just impossible.
0:13:45Your head will explode trying to merge them.
0:13:48You need to be very careful whenever you're working with one of these,
0:13:51primarily to make sure that you're not going to be crushing other people's problems
0:13:56or creating problems for other people.
0:13:58If two people edit a nib file and then you're trying to merge that together,
0:14:01you almost always need to just pick a winner
0:14:04and then reapply the changes that you made to someone else.
0:14:07Always be aware of that.
0:14:08Anytime you change a nib in a collaborative environment, make sure that you are pushing
0:14:13that very quickly and other people are pulling it before they make other changes.
0:14:16So just pro tip, I've made that mistake enough times to know that it's a big pain.
0:14:20All right, that's it for today's show.
0:14:23As always, if you have questions, comments, or concerns, I'm on Twitter @_DavidSmith.
0:14:26I'm on AppNet @DavidSmith.
0:14:29And otherwise, like I said, this is a great time if you have questions, specific questions,
0:14:33problems, things that you are struggling with, things that you are wondering about.
0:14:36I'll do my best to answer. Just hit me up on Twitter. If you want to email me, if you have a slightly more lengthy thing,
0:14:41I'm David@David-Smith.org.
0:14:43But otherwise, I hope you guys have a great week and weekend and happy coding. I'll talk to you later. Bye.