Effective PyCharm Transcripts
Chapter: Source control
Lecture: Loading a project with source control

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


Talk Python's Mastodon Michael Kennedy's Mastodon