Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Collaborating4:48 with Carling Kirk
Now that we've got the basics down, we collaborate with a team on our project and learn about branching and merging.
You know, it gets pretty lonely working on a project all by yourself. 0:00 I think it's way more fun to work on a team. 0:04 We can find a project we want to collaborate on and clone it. 0:06 Cloning makes a local copy of the files in a repository for your to work with. 0:10 You can clone a repository and push changes to it if you're a collaborator, 0:14 meaning that you have read and write permissions. 0:18 If you're not a collaborator though, 0:21 you'll need to fork it on github.com before you can push changes to it. 0:22 When you fork, you create a copy of an existing repository that you can do 0:26 whatever you want with. 0:30 You won't be able to push your changes, but you can create a pull request on github 0:31 to the original owner and if they like your changes, they can merge them in. 0:36 Let's search GitHub for TeamPowered. 0:41 Here it is. 0:44 There's a neat feature on github.com that appears once you've connected with 0:47 the Visual Studio extension. 0:50 This icon in the upper right corner now has an option to open repository with 0:52 Visual Studio. 0:56 Let's see what happens. 0:59 We've got a new instance of Visual Studio and the repository URL is filled in here. 1:02 Click clone. 1:07 Now our repo appears in the GitHub section. 1:10 So, this whole time we're been working in the master branch, but 1:13 that's usually not the best practice day to day. 1:16 Especially now that we're on a team, we should create a branch to work in so 1:19 we can keep our changes separate from the master branch. 1:22 If you look down here in the bottom right corner, 1:25 you can see the repository name, and the current branch we're working in. 1:27 There are a couple of ways to get to the branches pane. 1:31 We can click here and choose manage branches or 1:34 in team explorer, click on home, and then branches. 1:38 Let's create a new branch from master. 1:42 Right click on master, and choose new local branch from. 1:44 We'll call this clean up branch since we're gonna tidy up some code 1:49 This creates a local branch. 1:56 And remember, it's not synced with the remote repository yet. 1:58 We need to publish it. 2:01 You don't need to publish it right away. 2:03 But we can go ahead and right-click on the branch and choose publish branch. 2:04 Success, let's open up the solution, home and TeamPowered. 2:09 Wow, it looks like our team has been busy. 2:17 Let's open up the program class. 2:20 Hm, loadPersons, that doesn't sound right. 2:25 Let's change it to loadPeople. 2:29 And we need to change it down here too. 2:34 And we'll commit. 2:37 Let's see, change method name to be grammatically correct. 2:44 And commit, and sync. 2:52 Now we've got changes in our branch that aren't in the master. 2:58 But think about if somebody is making changes in the master branch. 3:02 We'll need to get their changes into our branch so 3:05 that we can keep the chances of conflict to a minimum. 3:07 We can try this out ourselves by switching to the master branch and 3:10 making some changes there. 3:13 Let's go to branches, double click on master. 3:15 Now we're working in the master branch. 3:19 Notice that our change went away. 3:22 Let's add a new class. 3:25 Add class. 3:28 And we'll call it role. 3:30 We'll commit. 3:37 Add new role class, 3:42 commit, and sync. 3:46 So to get changes from the master branch into our branch, 3:51 we need to merge from master. 3:54 Let's get back to branches. 3:56 First, we'll need to change back to our branch by double-clicking on our 3:59 branch name. 4:03 Now right click on our branch and choose merge from. 4:04 We want to merge from master into our branch, so 4:09 we'll choose master from the drop down here. 4:13 There's a check box here that lets us commit right after the merge. 4:16 If you want to review the changes before committing, 4:20 you should uncheck that option. 4:22 Click merge, and now we're merged for master and committed to our branch. 4:24 Let's go check out the history on our branch. 4:29 Right click on our branch name and choose view history. 4:32 It gives us this nice little graphic representation of our commits. 4:35 You can see our branch veering off and a commit was made and here's a commit that 4:38 was made in master and it comes back together when we merge for master. 4:42
You need to sign up for Treehouse in order to download course files.Sign up