Effective PyCharm Transcripts
Chapter: Source control
Lecture: Local history

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Now you know how to use a proper source control system like git,
0:05 it will be not super different for Mercurial or for Subversion or any of those other things. But— you don't always check in every change
0:13 and sometimes you really would like better more fine grained accuracy for the changes that have happened to your files.
0:22 Like, if you make a change and then you decide to throw that change away or you keep going and you end up breaking something
0:29 you are like oh, I wish I had checked it in, like 30 minutes ago and then I could roll it back to there, but I got a roll it farther back
0:36 because that's all the history that I have in my source control. Git solves this little bit with local check ins and you can have more fine grained,
0:44 but still I contend that there are times when you are like I really wish I had a version of this, and you don't.
0:49 So, PyCharm has this amazing thing called local history so independent of whether we were in a git repository
0:56 or had any source control configured at all, local history is always active and you come down here and go to a particular file and view local history,
1:04 there's not a whole lot to it, we could put a label or we could just show the history, watch this. Here is the life-cycle of this program.
1:12 Back here, we had zero files and then we created this one file here, right, and then we made some changes, so if you click through, it just shows you
1:29 all the various changes that happen, now it is starting to get interesting. l'll show you these files, how they've changed over time,
1:37 these are identical, here is another one, okay, so basically you get the various changes that you've seen over time.
1:46 Now, there's a bunch of changes that have actually nothing to do with this program.py so I'll just stay here, but this is really, really awesome
1:54 we've got local tracking of any change, and also it shows you where we checked in the other changes. Let's go and make some more changes
2:03 let's suppose first I'll put a label so this will be factored, saved, right you don't have to put labels but you can.
2:12 So let's go over here and let's import random and let's go and say start=random.randint and we're going to start somewhere between 90 and 110
2:29 and we're going to end by going to let's say 130 140 so we'll come down here and instead we're going to say start and let me put a save, end
2:46 and maybe let's put one line here again. So let's just run it and see what happens all right it looks like it went from
2:57 way back 105 to 137 was what it came up with the end. So that seems totally reasonable. Now let's go back to this local history one more time.
3:07 Now we can see some more meaningful changes so over here, we tagged it, notice when we do a commit it actually tags it automatically
3:14 but over here we get that as well. Now you can see we factored, we sort of labeled and we saved it and we made one change we came down here like this
3:26 and we said okay, we'll go and have this version and then, we can get this one, this is where we added that new line there,
3:34 so you can see, we started out with no randomness and then we added that random, I think this def is the current one. So this is what it was before
3:47 and then we go up here and then we added that new line down there. So things kind of moved around a little bit
3:55 but this is really, really helpful, I would say at least one time, I badly lost some file that I thought was in source control
4:03 and for some reason it wasn't, I deleted it and then I needed it back actually, it turns out I was able to use local history to get it back exactly,
4:11 so I don't use this often but when I do use it it's like really, really hopeful.
4:16 It's also great if you're working in a project that doesn't have source control set up yet, this is kind of like your wimpy source control,
4:23 super, super cool stuff, you can even do a little revert here. Okay, so local history— definitely, definitely check it out
4:32 it's a parallel, independent version control that only lives in your project files.


Talk Python's Mastodon Michael Kennedy's Mastodon