GitHub in Workspaces9:46 with Kenneth Love
GitHub is a great tool for collaboration and no fuss version control. But sometimes you want to be able to work on a project from any computer connected to the Internet or you just don't want to set everything up on your own computer. Workspaces is a wonderful way to have a development server while you're a Treehouse student. Let's see how to use both of these powerful tools together.
[MUSIC] 0:00 Workspaces is one of my favorite features here at Treehouse. 0:04 It combines a terminal, a file browser and a text editor all into one and 0:07 even let's me run a server like when I'm using Django and Rails and see the output. 0:11 I've been lucky enough to use it almost everything I've taught and 0:16 I have no plans on stopping that anytime soon. 0:19 One of the questions I've been asked several times, 0:22 though is if you have to give up workspaces to be able to use GitHub. 0:25 This question has a surprisingly tricky answer. 0:28 If you're to the point where you want to put your work up on GitHub, you're 0:30 probably to the point where you should be working locally most of the time. 0:33 Development will probably be faster for 0:37 you, you'll be able to use your favorite tools and some workflows will work better 0:39 on your computer than they will on the Workspaces server, but you don't have to. 0:42 If you love Workspaces or need to be able to work on something from any computer 0:48 that's connected to the internet, you can stick with Workspaces and 0:51 take full advantage of GitHub. 0:54 Let's go to the source, Workspaces and see how to use it with GitHub. 0:57 Just like working with GitHub on your own computer, 1:01 the first thing you probably wanna do is create a repo. 1:04 Now, I can do this in Workspaces or I can do it on GitHub itself. 1:07 I don't really have a preferred way, so 1:12 I kinda just do whichever one seems more expedient at the moment. 1:14 So, I'm gonna start on GitHub. 1:17 So here, I am on github.com as you can already see. 1:20 And up here on the top, there is this plus button. 1:24 And if you're on your profile page, 1:27 there's also this newer repository button down here. 1:29 So I'm gonna click the create new and I'm gonna choose new repository and the button 1:32 might be in a different spot, just because GitHub does change their UI around. 1:37 I always end up having to look for it. 1:43 If you can't find it, there is a link down here to Help and 1:45 they have really good help documentation. 1:48 So, I need to name this repository. 1:51 I think I'm going to make a little reminder script. 1:54 Like something that I can use just to, hey, remind me to take out the trash. 1:57 Remind me to write that documentation. 2:01 Remind me to release a course. 2:03 So I'm gonna name that rememberer, cuz it does my remembering for me. 2:05 If you don't have a name, then GitHub actually gives you one, 2:12 which is kinda cool. 2:15 So potential-octo-adventure, that's actually a really great name. 2:16 Anyway, so for the description, 2:20 I'm gonna give it a quick description of what it does. 2:23 Lots of times people leave projects without a description. 2:27 That just really annoys me. 2:29 I'm gonna say, remembers things for you so 2:31 you don't have to and I'm gonna make the repository Public. 2:34 We have to pay for private repos. 2:39 If you don't have them, then you'll have to upgrade your account. 2:41 I don't care if anybody sees those codes, I'm gonna make it public. 2:44 I'm gonna go ahead and initialize it with a README, 2:47 just so there's a file in there and I'm going to, this is going to be python. 2:50 So, I'm gonna add a python get ignore. 2:54 And for licensing, I'm a big fan of the BSD 3-clause, but the MIT. 2:57 I mean, all the licenses are okay, so pick whichever one you want. 3:03 So I'm gonna do that, just because I wanna get this stuff in there. 3:06 So I'm gonna create that repository and cool. 3:10 So there's my repository and up here for cloning, 3:15 there's an address here and you can choose to do it between HTTPS or SSH. 3:19 The HTTPS one is a little bit easier, 3:26 you don't have to deal with SSH key and a passphrase. 3:29 So, I'm just gonna go ahead and copy that to my clipboard and 3:32 then I'm gonna come over here to Workspaces. 3:37 And I've already clicked the new Workspace button, so I'm gonna go ahead and 3:40 make a new Workspace now and I'm gonna say, it's the Rememberer Project and 3:44 I'm building this in Python. 3:48 So, I'm gonna put Python there. 3:50 Now of course, whatever language you want to use, go for it. 3:51 You don't have to do this as Python. 3:55 You can do this as anything you want and then I'm gonna hit create Workspace. 3:57 So, awesome. 4:02 Now, we have a great Workspace. 4:04 Let it spin up and then let's see. 4:08 Down here in this bottom part, this is my terminal. 4:12 So down here's where I wanna clone, I wanna check out my project. 4:16 So I'm gonna say, git clone and 4:20 then I'm gonna paste in the repository 4:23 address that GitHub gave me, press Enter. 4:28 Wait for a second and then I'm gonna Refresh the sidebar and 4:33 looks like I have a Rememberer Project. 4:37 So, that's pretty cool. 4:40 I have my License file. 4:41 My God, shrink that down. 4:43 I have my LICENSE file and I have my README.md. 4:44 So, great. 4:47 There's everything that I was looking form, but 4:48 this README.md is really bare because it just started. 4:50 It doesn't really have anything impressive in it. 4:53 So, I'm gonna fill this out a little bit more. 4:56 Lots of times when I'm first starting on a project, 5:00 I like to do what's called read me driven development and 5:03 the idea is that basically, you write docs about how your project works and 5:05 then you write your code, so that your docs are telling the truth. 5:09 No one likes lying documentation. 5:12 So let's say, Usage and we'll say, 5:15 'remem take out the cat litter' and 5:19 that will add a new item to be remembered and 5:23 'remem --list'- print out the list of things to remember. 5:28 'Remem --delet 2'- delete 5:37 the item with index 2 and 'remem 5:42 --next'- print out the next thing to do. 5:47 That's a pretty good README.md. 5:54 I obviously, have quite a bit of work ahead of me. 5:56 But I have made a change, so I need to make a commit. 5:59 So, I'm going to come back down here to my terminal and 6:02 let's do git status and fatal. 6:07 Not a get repository, that's right, because rememberer is the git repository. 6:10 So, let's get into rememberer and 6:17 now, we can do git init. 6:22 That's not what I wanted to do, I wanted to do git status. 6:26 There we go. 6:30 So, I have this README.md file that has been changed. 6:32 So, I need to add that change in. 6:37 So I'm gonna add the READMe.md file and them I'm gonna do a commit and 6:40 I'll say, "add example usage to README". 6:48 And so now git doesn't know who I am, 6:52 so you might have to add this yourself. 6:56 And basically, you just want to copy and do what git has here. 7:00 So, I'm gonna do git config user.email "firstname.lastname@example.org" and 7:03 you'll notice that git lets me do this --global and I'm leaving off --global. 7:09 The reason for that is the --global goes to the system wide git so 7:15 that it remembers who you are. 7:19 The system wide git isn't going to be the same from workspace to workspace. 7:22 So I want this to remember me just for the repo and 7:27 user.name will be "Kenneth Love". 7:32 So now, let's check out git status. 7:37 So our thing was added, but we haven't committed it yet. 7:41 So let's rerun our commit, cool. 7:45 So, we added the example usage to the README.md and 7:50 now I'm gonna go ahead and push these up to GitHub. 7:53 So I will get push origin master, which is the default and 7:56 now I have to put in a username. 8:01 GitHub is going to ask you for your username and 8:03 your password every single time and that's because GitHub on 8:06 Workspaces doesn't store your identity, which is a good thing. 8:10 It's fine, we don't want our identity store on Workspaces. 8:15 So while it's annoying to have to type those in, it's great for privacy. 8:19 So, it's okay. 8:24 It makes pushing a little bit tedious, what I normally do if I'm going to be 8:25 working in Workspaces is make as many commits as I can before I push and 8:29 I just push like when I'm pretty much done with something. 8:33 You probably don't want to do that with a team, 8:37 because your team is probably going to want updates more often. 8:39 But if you're working on a feature branch by yourself, it's not that big of a deal. 8:42 So, let's check out GitHub and see if my changes came through. 8:46 So, we have two comments. 8:53 And if I look at the README.md, then yeah, I have my stuff. 8:54 It's not formatted great, but it's there. 8:58 So now, it's time to actually go build this thing. 9:02 I probably wanna go fix my README.md, so 9:05 that it comes through in a better format, but it all works. 9:08 So I'm gonna go work on this, 9:12 I don't wanna keep the rest of you from the rest of your day. 9:14 So, I'll do that on my own and 9:17 you can go build whatever it is that you need to build. 9:18 Like I said earlier, 9:21 you probably want to work locally by the time you want to put work up on GitHub. 9:22 Go for it. 9:26 Installing Git on you computer is pretty straightforward. 9:27 But whether you use your machine or Workspaces, the important part 9:30 is building up projects on GitHub and helping others with their projects. 9:33 If you want to learn more about Git or GitHub, 9:37 check out our courses on each of those. 9:39 A link to them both in the teachers notes. 9:41 Good luck and I can't wait to see what you built. 9:44
You need to sign up for Treehouse in order to download course files.Sign up