Mastering PyCharm Transcripts
Chapter: Source control
Lecture: PyCharm git flow and PRs

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's begin our exploration of this git flow in PyCharm by creating an issue.
0:05 Let's suppose one of the problems is our little podcast downloader thing
0:10 it doesn't get the latest episodes, potentially,
0:12 there's actually no way for it to know what the latest episodes are
0:17 the way that we created the api.
0:19 I'm going to come over here and say add latest episode tracking
0:25 that's not a great word for it,
0:28 but we'll go with that the latest episode tracking for downloader.
0:33 I'll assign it to myself, I'm going to label that as an enhancement.
0:37 This is the description, so we'll come back to that later.
0:43 We have our issue being created,
0:46 and our issue is a number 2, remember that number.
0:51 So we'll go over to PyCharm, and first of all,
0:53 notice we have no pending check in changes
0:56 and we can also update to make sure we have the latest,
0:59 we're on master, all files are up to date, great.
1:03 Now what we want to do is, I would like to work with that work flow
1:07 I would actually like PyCharm to know about not just git
1:10 but github and the issues— how do I do that?
1:12 Well, it's not anything I've shown you yet
1:15 it's hiding up here under tools, not under version control.
1:18 So if we go to tools Tasks & Contexts,
1:22 we can go over here and configure servers
1:24 this is a lot not obvious, but this is how you do it,
1:27 you go to servers and you say, I'm configuring—
1:30 look at all those bug tracking things, YouTrack, Jira, FogBugz,
1:36 Trello, GitLab, but we're going to add github.
1:42 So I'm going to come over here and I am going to put my username
1:45 and then we need the repository name, so that is this part right there
1:52 I am going to put that there, and now what I need to do is
1:54 put an api token in there and I could press create
1:57 but this is actually kind of sensitive, so I'm not going to show you this.
2:01 Okay, I pressed okay, and notice up here,
2:07 I was kind of hiding that, played with it a bit,
2:09 this little default task thing has appeared,
2:12 and if I go under tools, task, I can now open a task
2:17 either way I could do it here or there, but if i click on this
2:20 notice that I get some stuff right here,
2:24 we have random common things that we've done recently,
2:27 these are like check ins and stuff or I can hit open.
2:30 Now, if you wait for a second, this will download the various issues
2:34 so these are basically repository name-issue number 2
2:41 so add the latest episode tracking for downloader,
2:44 yes that's what we want to do, let's do that.
2:45 So I click it and it says okay great,
2:47 what we're going to do is we can clear the current context,
2:51 we're going to create a change list for all the changes
2:53 we could even shelve pending changes, if I had them;
2:55 create a new branch, I don't like this name here
2:58 so I like to do this in mickeckennedy username something about the issue
3:03 so we'll say 2-track feature, or let's call it track latest.
3:09 Okay, notice we're going to branch it from master here
3:14 or we could actually use an existing branch if we want
3:17 but I'm going do this git work flow
3:19 go to the issue, create a branch, a feature branch for it,
3:22 base it on master so when we merge it back
3:24 it's going to go back into master and we'll go from there.
3:27 So immediately notice down here,
3:29 we're in this new local branch that's getting checked out
3:32 up here it tells us what we're working on, things like that
3:35 and we'll just go do our work.
3:37 So let's go down here, and the reason that we don't really know the ending,
3:42 is if we look at this api in this thing
3:45 there's really only two functions,
3:47 there's download and then there's get_an_episode,
3:49 give it the id and you get it back, maybe.
3:52 So, notice that here's a dictionary and it contains the keys the episode id
3:59 so let's say get count, or let's say get latest show id
4:09 down here we'll just do something like return max of episode_data.keys
4:14 all right, we'll probably test if that works
4:20 let's go up here, do a quick little print,
4:24 print working with total format service.
4:32 now we should have get our latest show id,
4:38 and then we'll use this again down at the bottom,
4:41 so instead of going to random, we'll do that plus one
4:45 so we're always working on the latest.
4:47 Let's go and give this a run and see if it's working.
4:51 Hey look at that, if we go at the top
4:55 we're working with 140 episodes, let's see if that's right.
4:59 Go to the episodes, 140, beautiful,
5:05 so it looks like that is working and we're happy with it right,
5:08 we've tested it, we made all of our changes.
5:11 Okay, so what we're ready to do,
5:13 notice, we have pending changes, both these were changed
5:15 and we're going to go over here and I would like to close this task
5:19 tools, task say close active task
5:26 and when it says that, it's like okay what do we want to do,
5:28 do we want to commit the changes,
5:30 do we want to merge the branches back together;
5:32 do we want to update the issue state to make it resolved?
5:36 So notice over here, if I refresh— still open.
5:40 Okay, let's do it.
5:49 So we've deleted the branch, we've merged it into master,
5:52 notice we're back on master here, go over here refresh
5:59 the issue state is now closed,
6:04 and do we have a closed pr? No.
6:11 So you can see that was all done,
6:13 if we go back to our master branch,
6:17 we've got this change that happened just a minute ago,
6:22 let's go look and see if it actually made the change here.
6:29 It looks like it did not, so all we have left is this sort of "random gets" so check that in,
6:33 so over here we just have the two functions
6:35 we have download and get episode
6:38 so we're missing or get link
6:41 because we have not yet actually created the pr for this
6:45 so we got to go over here and say
6:48 compare this so this fixes issue number two,
6:54 notice, we even get little intellisense, thank you github.
6:56 So we can go create this pr,
6:59 maybe someone else or even me will come along and say,
7:02 oh look there's an open pull request I need to deal with it,
7:05 in here and I can merge it, confirm my merge, change
7:12 if I really want I could delete that branch
7:17 if we go back to master,
7:25 we now have this check in here, not the greatest name
7:28 but if we look at service, we have our new little feature thing,
7:33 it's hard to call it much of a feature, but you know what, there it is.
7:37 Now if we go over here and we look at it,
7:40 do we have it yet— yes, it is merged in locally
7:44 PyCharm did that for us, but it didn't do the pr
7:47 actually, the more I think about it, probably following the git flow
7:50 I don't think I would merge it locally into my branch
7:52 or close the associated issue,
7:55 I think I would go over to github and do that
7:57 but if you're not working with github maybe it makes more sense to do it this way.
8:01 Either way, so if we go over here and we look to push our changes back
8:05 notice, first of all, there should there be nothing to commit
8:11 other than unversioned files, if we over here and we do a push, git push
8:16 we have this local merge that we did there,
8:20 I don't think that we really need to do that let's just do an update,
8:28 alright, all files are up to date, now there's no change left to commit
8:33 because we kind of did it in those two places right
8:36 like I said, I would do this in github rather than just in PyCharm.
8:40 Now we can go over here and just go back to our default task
8:43 it says our empty change list is no longer active, that's great
8:47 so let's just get rid of it.
8:50 Alright, there you have it, that's the git flow in PyCharm.