Creating a Repository5:04 with Carling Kirk
We create a new GitHub repository right in Visual Studio and create a new project. We make our first commit and learn to navigate in Team Explorer.
Include/Exclude vs Stage/Unstage
After this workshop was recorded, the GitHub Visual Studio extension was updated as part of Update 2 for Visual Studio 2015. The GitHub integration in Visual Studio 2017 also includes these changes.
The sections in the Team Explorer "Changes" panel that were labeled "Excluded Changes" and "Included Changes" are now labeled "Changes" and "Staged Changes" (respectively). Additionally, the context menu items that were labeled "Include" and "Exclude" and now labeled "Stage" and "Unstage". These labels were updated in order to use terminology that would be more familiar to experienced git users.
Also, changes are not staged (or "included") by default as they were before. This approach allows you to select which changes to "stage" for your next commit. Or you can choose to "Commit All", which will commit all of your unstaged changes.
For more information on these updates to the GitHub extension, see this article on the Visual Studio website:
Okay, we're in the connect section. 0:00 If you don't see this right away, 0:02 click on the little plug icon on the top of Team Explorer. 0:03 Now we can click connect, and enter in our user name and password. 0:07 GitHub also features two factor authentication, 0:14 which will prompt you for a code. 0:16 Now we're authenticated. 0:18 Let's create a new repository, or repo for short. 0:20 Click on create, 0:24 I wanna create a new application that will help me organize teams. 0:25 Let's name this one TeamPowered. 0:29 And for the description I'll put This project is to help manage teams. 0:33 The local path is where your physical files will live. 0:43 I'll just leave it as the default, but you can put them wherever you'd like. 0:45 Git ignore, so this option will let us pick from a variety of languages and 0:50 frameworks. 0:54 It's defaulted to Visual Studio. 0:56 This option will generate a Git ignore file that includes a default set of file 0:58 extensions. 1:02 We only really care about the actual source code files in source control, and 1:03 we don't want to track changes to other types of files in a project, 1:07 like Visual Studio configuration files. 1:10 The Git ignore file specifies the types of files that will be ignored when committing 1:13 changes to the repo. 1:17 As for the license, you can apply a license to your repository that tells 1:19 other users how they can use your code. 1:23 If you wanna learn more about open source licensing, 1:25 GitHub has some great documentation, check the teacher's notes for a link. 1:28 I'm gonna leave it unlicensed. 1:33 This means that nobody is allowed to use my code, but 1:34 we can always open source it later. 1:37 Create, we click on the home button to get back to the home section of team explorer. 1:39 Here's our new repo. 1:46 Let's create a new project and add it to the new repo. 1:47 Normally you would create a new project from the file menu but 1:50 if you wanted to be in a local Git repository, 1:54 you should click in the solutions section down here and click new. 1:56 That way, it'll automatically fill in the directory of your Git 2:01 repositories instead of the default Visual Studio location. 2:04 We'll make it a Console Application, and let's call it TeamPowered. 2:07 Here's our shiny new project. 2:17 We'll switch over to the Solution Explorer window. 2:19 You can see these little plus icons next to each file in the solution. 2:22 That means that they are new to our repo. 2:26 We need to make a commit to start tracking their changes. 2:28 Let's switch back over to Team Explorer and click changes. 2:31 Here we can see all the files it detects we need to commit. 2:36 And the operations are next to the names. 2:39 All of our project files will be added. 2:42 It's good to review the changes so you can make sure you've got everything included. 2:44 Or if you need to exclude something, we can exclude a change by right clicking and 2:48 choosing Exclude. 2:53 When you're ready to include it again, you need to right click and choose Include. 2:55 If you never wanna add the file to the repo, you'll need to put the file name and 3:01 then, Git ignore file which will be in the root of your repo directory. 3:04 We also need to write a commit message. 3:09 It's really helpful to put as much information as possible in your commit. 3:11 Sometimes, when looking back at earlier commits, I say to myself, 3:15 what was I thinking? 3:19 Your future self will be well-informed of why you made the changes, 3:20 instead of having to go dig through the code. 3:23 This goes for your teammates too. 3:25 I'm just gonna type in, first commit and 3:28 let's click on commit, and now we're committed. 3:33 Remember though, that it just commits locally. 3:38 You can see here that it says commit created locally, 3:41 sync to share your changes with the server. 3:44 You don't have to sync right away, you can do several commits and 3:48 then sync them all at once if you'd like. 3:50 This is helpful when you want to group commits together or 3:53 work completely isolated from the remote repo for a while. 3:55 Let's click on Sync. 3:58 This is the sync pane. 4:01 When we clicked on sync, 4:02 it asked the server if it had any changes that were not in our local repo. 4:04 On a team, for example, it's possible that another developer changed a file in their 4:08 own copy and we need to get their changes into our local copy. 4:12 This lists all Incoming Commits that we'll need to pull down, and Outgoing Commits 4:16 that we've made that haven't been synced or pushed to the server. 4:21 If we click Sync again, all changes will be synced. 4:24 We can also pull and 4:29 merge incoming changes before pushing our outgoing changes. 4:30 We have to pull and merge any remote commits before making our push. 4:34 This is so we can make sure our code won't conflict with anyone else's that's already 4:37 synced with the server. 4:41 We'll take a look at an example of this in a bit. 4:43 Let's go check out our code on GitHub.com. 4:45 On the home pane, we've got a few shortcuts to different features of GitHub, 4:48 and they'll get us to the repository. 4:51 We'll click on Graphs. 4:53 This shows a graph of all the commits in this repository. 4:55 We've only got one. 4:58 We can click on Code to see if our commit is there. 5:00 There it is. 5:03
You need to sign up for Treehouse in order to download course files.Sign up