Effective PyCharm Transcripts
Chapter: Source control
Lecture: Accessing source control

Login or purchase this course to watch this video and the rest of the course contents.
0:03 To start our exploration of source code and its integration with PyCharm, let's just look at our github repository here, mastering pycharm course,
0:11 we've already talked about where this lives, but you'll notice that there's really nothing going on here
0:16 like a little while ago, I put the course image and I've updated the read me apparently but nothing has been committed
0:23 and also notice that there are two branches like imagine, this is just to sort of pretend, I'm doing some sort of feature branch thing
0:29 so I've got this feature branch one and maybe I'll issue a pull request back to the main master branch.
0:37 What we want to do is we are going to go back to the code that we already wrote
0:41 and when I first did that, we did the editor stuff and the project stuff what I did is I created a folder called "demos" in here
0:48 but I didn't check it in or anything, because we hadn't gotten to the source control part yet. So here we are in one of those programs
0:55 remember we got one, we can go and download from the podcast so I could run this and it will tell us what the items are
1:02 basically available on Talk Python right now. So you can see that we're getting, I guess we are getting the 0 to
1:15 129th one down here, we're not getting all of them. Here in program, we're only showing this little bit.
1:20 You can see this is working fine, but it has not been checked into source control so how do we go about this?
1:26 I created this folder inside, let's go to my desktop, I created this folder here inside the course,
1:34 here you can see the read me, and all those kinds of things. We go over there, let's say go to the desktop course,
1:40 this is a git repo, and we have some files in here, some that are new, some that are modified okay, so let's go check that out.
1:51 Now, if I just open this project, automatically it knows it's part of git, so go to the menu first up here notice there's a bunch of non grayed out
1:59 commit, update source control options and we could go and say check out from github or some other types of things, but because we've already opened it
2:12 there's actually a lot of git features available to us. So we could commit a file, we could add it,
2:17 we can merge changes, we could reset it to the latest, all of these sorts of things. I could even create a pull request, how cool is that.
2:24 So a lot of stuff can happen up here notice there is also a local history which is amazing we'll talk about that in a minute.
2:30 For now, we're going to focus on the real, grown up git source control stuff. So, this is all great, you might use that,
2:38 but typically I find myself here extremely rarely. So let's look down here, notice this, it says git master, how awesome is that?
2:48 Because we're in a repository it automatically knows, actually the very first time we opened it, it noticed it was a git repository
2:54 and it asked should I add integration for it and I said yes, so that's technically the yes it's required,
3:00 but down here now if I click on it, I get branch information. Notice I could tag a branch, create a new branch, I'm on master local
3:06 and on remote, I have my feature branch so I could do things like check it out, because it doesn't exist in local and things like this
3:15 so we'll come back to the branching, but notice right away it tells us sort of where we're working and then up here, these are all the run options
3:22 but on the right, we have update project, commit the changes, this shows the history, not committed, so there's no history, we'll revert it back.
3:32 So this little group of four things is also your source control. And finally, it might not be obvious yet,
3:38 let's go ahead and mark this as excluded so we don't look at it, the green here actually means this is a new file
3:47 so if I go back over here, it is this little bit right here. The green means new file here, if it were modified it would actually be blue not red,
3:59 and if it were not tracked it would be basically that color. So if I go over here and I add another file let's just call this other.txt,
4:08 I told PyCharm when I created this project that it was allowed to automatically add things to source control,
4:15 but if I added it without, it would show up as red. So now let's go ahead and commit these,
4:21 probably the first thing we want to do is get the latest changes. So we can go over here and say get me the changes and we'll just pull those down,
4:30 it says okay, everything's up to date, great. Now let's go ahead and check them in, so let's go commit, so we'll come down here and it says
4:37 these are all the files that we're actually going to commit for you there's some project files that's going to track for us
4:44 but these are the ones that we're looking at and then there's a bunch of unversioned files that it's not tracking
4:48 some project files that we could ignore we'll come back to that later. Okay, so what we want to do is we want to check those in,
4:56 we'll give it a message, whatever it is you do when you do your check in so this is committing the early work.
5:05 We could come over here and reformat the code according to our rules before we check it in, we could do certain things like optimize the imports,
5:14 perform code analysis, other types of clean up. So there's all sorts of stuff, we could even push it to production if you would like,
5:21 I am not a fan of that but you can. So down here you can see your differences, this is all green because it's all new, not a lot going on.
5:29 Now remember git is two staged, so if I just click commit, it's just going to stage it locally,
5:34 what I really need to do is commit and then push those changes up, so I'll do that all in one shot. And it comes back, it says
5:43 okay you need to push this stuff, you are going to push it here, we could push tags and things like that, but let's just go.
5:48 Wait a second— ta-da, it was updated. Now if we go back to github and we refresh, There it is, committing the early work, 17 seconds ago.
6:01 So we come down here, we were on this one, the podcast. So, down here we're got the work that we did, awesome.
6:09 Let's go over here and make some changes, because we're not quite done exploring this yet.
6:14 So I told you if we made some changes that the color would change again, so let's go and suppose in program, what we want to do
6:22 is we actually want to get 120 to 141, so we made some changes here, and if I go over there,
6:31 notice it's already turned blue, that means it's been changed, it was in source control, it's been changed.
6:36 I can come over here and I can save, and we could say show me the history now, now we have some history, right, this was checked in,
6:44 so we have our local changes, our log of what has been changed, our console down here for our git action,
6:51 and then this, we could actually show the diff on that is not super interesting yet, is it; because we just checked it in.
7:03 Alright, so last thing, let's do it from here, actually this one from here, so we could compare with the current version,
7:12 now we can see that we've changed this one line, right, so this is standard git changes.
7:20 Okay, so pretty awesome, let's just go and push our final change up, later episodes, something like that, and we'll do a commit and push,
7:29 and push, awesome, I'll commit it. Finally, let's look at annotations, so if I click on annotate, it will come along an it will say
7:45 who has made these changes, when the changes were made, you can click here and it will actually show you that check in, right,
7:52 if I click on this one, it will say look we just checked in that one file with this change, if I click here— now it's not super interesting
8:00 because there is only 2 versions and it was all me, but you can imagine in a real application in a real project over time, this annotate is super cool.


Talk Python's Mastodon Michael Kennedy's Mastodon