Effective PyCharm (2021 edition) Transcripts
Chapter: Source control
Lecture: Loading a project with source control
0:00 One of the things I love about PyCharm is its deep integration with source control.
0:03 It makes it feel so natural that you almost don't have to think about it.
0:08 So let's start by getting a project from GitHub now.
0:13 There is this button up here,
0:15 Git code from source control and I could come over here and type something in,
0:19 let's see the various options. Or I could even go over to mine,
0:23 GitHub account and click here and give me a list of all the GitHub
0:27 repose I have access to. And that's one thing I'd like to kind of start
0:31 from a different perspective though I'd like to start from.
0:34 Well let's just suppose you have a GitHub or some other kind of repository on
0:39 your system. How do you work with it?
0:41 So we're going to actually go over here to the GitHub repository and we're going
0:44 to clone it. Now when you clone a repository,
0:48 a lot of times you can come down here and copy this and it would show
0:53 that you gotta put the little Git thing on the end the extension.
0:57 But if you just copy the main repo name,
0:59 actually that's sufficient. So I want to clone that over to this location.
1:05 So I just made a folder,
1:06 let's suppose that's where I put my projects that I'm working on.
1:09 I'm gonna open up my terminal and I'm just going to type git clone this off
1:17 it goes let's cd in there really quick notice my prompt knows which branch I'm
1:23 on and all of those sorts of things,
1:24 I actually want to work in the ref one for now.
1:28 But when you get to the course I'm gonna swap it back to the main so
1:31 you'll be fine. And so git check out by the way with oh my Z
1:37 shell integration it actually gives you auto complete for the branch names.
1:41 I love that. I want to open up this project we have here in
1:46 PyCharm and have it work with the source control.
1:48 So like before what we could do is we could grab this and throw it into
1:52 PyCharm and it will open up but I actually want to work with just a
1:55 certain section. I just want to work with the podcast section.
2:00 So what we're gonna do is I'm going to throw that in here and you'll see
2:02 some really cool stuff. First of all,
2:05 PyCharm realized that there is a 'requirements.txt' and when there's a requirements.txt
2:10 that usually means you need a virtual environment.
2:14 If you're going to install third party packages,
2:16 you must be you really really should consider having a virtual environment dedicated to that project
2:20 So PyCharm is now helpfully suggesting that I'll go and let it do that
2:25 Now if we go over to our program here notice it says you're gonna need
2:28 requests to run this. So let's go and let that install.
2:32 So we've opened up our project but check this out.
2:36 We also already have git integration.
2:39 So we're on this ref branch,
2:41 if you click down here this whole list,
2:43 the branches and it knows which branch were on.
2:46 Remember I checked out that ref branch started main went over to ref So because this
2:53 file lives in the hierarchy of a Git hub repository,
2:57 low or git repository locally. PyCharm automatically detected that an added source code integration
3:03 For git how cool is that?
3:07 So now that it knows how to do things,
3:09 it knows that there is an active Git hub repo or get repo we have all
3:13 of our source control commands in particular.
3:16 This time it's a Git. If we opened up a subversion repository,
3:20 well then it would give us subversion commands.
3:22 So over here we've got things like update the project.
3:25 Notice all of these have hot keys basically.
3:28 So if we wanted to, you know,
3:29 we had changes on the server,
3:31 we could either click this button or command T and it will say we're gonna emerge
3:35 changes into the current branch. Or we could re base it.
3:39 Typically what I end up doing as I say,
3:41 don't show this again and just leave it as the default.
3:44 That's usually exactly what I want.
3:47 And then I could commit changes.
3:48 We don't have any changes yet,
3:50 but if I did and we have a change,
3:52 I could commit the change over here will show me details about that.
3:56 I could push the changes remember git is a two stage system.
4:00 I make changes but those changes build up locally in the repository and then when I'm
4:05 ready, all of those changes get pushed up to git hub or whatever the server is.
4:09 I can view the history of this file and here's all the different things
4:14 that happened to it and so on.
4:16 Very neat and I can't even revert it.
4:18 Suppose I don't like this change that I put here,
4:20 I say no, no, no,
4:21 just go back to the way it was and I love that feature.
4:24 I love it when I was exploring and going crazy and I'm like now that wasn't
4:29 the way I wanted to go push that button.
4:30 It goes right back to the last save point.
4:32 Also if you look up here,
4:34 there's a Git menu with even more options.
4:36 So we could merge things, we could work with branches,
4:40 we could check out the log,
4:41 we can do all sorts of stuff over on GitHub.
4:43 Like if I had forked repository,
4:45 I could sync it back. I could create a pull request.
4:48 I want to talk more about some of these things as we go.
4:51 But there are a lot of features available to as soon as git repo that are
4:55 not available directly right here. But the common ones you need right appear in source control toolbar.