>> On today's Visual Studio Toolbox, we're going to see how easy it
is for Visual Studio users to adopt Git and GitHub for all
your source control needs. [MUSIC] >> Hi, welcome to
Visual Studio Toolbox. I'm your host Robert Green, and joining me today are
Sachin and Samit. Hey, guys. >> Hey, Robert. >> Hey, Robert. >> Welcome to the show. >> Thank you. >> Thank you. >> We're going to be talking
about source control, which on the face of it seems
like a pretty dry topic, but we're going to be talking about using Git and GitHub to
do your source control, and how well integrated
it is into Visual Studio, and how easy it is to do
source control in Git. So it actually winds up being
a pretty exciting topic. >> Absolutely, yeah. >> Lot of interest in it. >> Yeah. Git and GitHub are absolutely exciting stuff
to talk about. Today we are going to
learn about how easy it is for GitHub users to
start using GitHub, and safely bring the open source
workflows within their companies. So before we begin and
teach about how to do that, let's step back and just say why, why should I move
my source code management to Git and GitHub in particular? >> That's a great question and
you always start with why, why do you have to
care about something? Git is a modern version
control system. You know that has won the hearts and minds of developers worldwide. It has become the leading
choice for many teams, and it's the number 1
version control system out there in the industry. There are several factors
that contributes to the success of Git: it's free, it's open, it's lightweight,
and it's distributed. But in a top factor for
the quick success of Git, I would say is the GitHub. GitHub provides
enough free repositories for open-source public projects. We have about 100 million
repositories with 33 million developers actively
contributing on GitHub. It also provides
GitHub Enterprise for organizations that demand security, compliance, and
more deployment controls. >> Cool. >> Well, so GitHub Enterprise are they public repos or
are they private repos? >> They are private repos. We want to bring that GitHub, the open-source
development in a bag into your organization
inside the firewall. That's GitHub Enterprise for you. >> Awesome. Those numbers
are impressive. You said 33 million
developers, right? >> That is correct. >> A 100 million, so that's on average three some above-average,
that's good to know. >> Yeah. Absolutely. So Sachin, how exactly is Git different
from say subversion or TFVC. >> Yeah. So unlike in
a TFVC or Subversion, Git is a distributed
version control system. So what that means is, the changes, the historical data is not
stored on a central server, but every developer gets a copy of the repository and
download it onto their machines. So that means you can
do all your version controlling within
your local repository. You could do that even
when you're offline. When you come back online, when you get connection
to the server, you can push all those changes. >> It's a lot faster too. >> That is right. >> Right. So this is
completely different from central version
control system where every developer has to be
connected to the central server. >> That's awesome. Yeah.
But then if I'm new to Git, will that be a steep learning curve? >> That's a good question.
GitHub provides several options for you, like in a GitHub desktop
and GUI that makes it easy. But having said that, if you are completely new to the distributed
version control system model, there could be a learning curve. But thanks to Visual Studio, we make it so easy for
our Visual Studio users. We have a GitHub extension
that makes it so easy for developers to connect and
download and work with GitHub. >> Yeah. Like most things there's
a command language you can use. You can go into the command
Window and type "Git commands", which is not a bad way
to learn it the first couple times like push, pull. You get to learn what those mean. But pretty quickly, a lot of people may include
get tired of typing, and we just want to integrate
it into Visual Studio, and let Visual Studio
do all the work. So, it's same thing
with Azure portal. You can do everything in the portal, not a bad idea to play around
with the CLI and the commands, but eventually you might want to just head back into
Visual Studio and let it do. >> Like me, once you get
familiar you like to use the CLIs and that's much faster. >> Yeah. >> Also you don't want to toggle between too many
applications and Windows. You want to work from one place. For a Visual Studio user of course that one place
is Visual Studio. >> Yeah. So you want to show us. >> Oh, yeah, sure. So let
me get to my machine here. So as you can see, I have Visual Studio 2019
installed on my machine. >> Brand new, this is
the Visual Studio 2019. Yeah. >> Yeah. Just released
a few weeks back. So what you see is, right on the "Setup page"
we have an option for you to connect and download
and work with GitHub. That's because we have this extension that comes
with the installer. So you can install it and when
you install Visual Studio 2019 or if you haven't
upgraded to 2019 yet, you're a 2015 or 2017 user, you can go to the Visual
Studio marketplace and download an extension
and install it. >> Right. >> Once you have it installed, you can connect to GitHub from here. But I'm going to start
from the scratch. I'm going to show you how to put
a project into a GitHub first. So let me open up project that's
on my local machine here. So I'm opening up this
Parts Unlimited project. This is not yet on any version. >> It's unlimited man, it's
always making a huge comeback. >> Absolutely, yeah. >> He said was on the last show, he was using Parts Unlimited, you guys you're using
it, it's an old- >> I'm a big fan of Gene Kim, I have read his phoenix project. >> It's a Parts Unlimited
Renaissance here in Toolbox. >> So let me open up my project here, and what I'm going to do is, I'm going to place this into
version control system. So here as you can see, and as you can expect from
Visual Studio, you have options. So I'm going to add this, and
you will notice from the output Window a new Git repository
is created by Visual Studio. So this is a local Git repository. >> Right. >> So now, a version
control is created, now I can start on making changes. I can do the equal and
tough, checking my code. When I'm ready, I can
push this to my GitHub. >> So the key there is, this is now under source control using Git, which is basically
the source control plumbing, and then you could
just use Git locally. You don't have to use GitHub, you don't have to use
the other places that support Git like Azure DevOps
and there's others. So again, getting back to one
of the benefits of Git is, because it's distributed,
you could do it all locally, and if you're never going to
share the code with anybody else, and you're never going to
use more than one computer, and you don't want to backup
stored somewhere else, then you wouldn't have to put
the code someplace like GitHub, but you probably want to. >> You want to do that. >> You have no other reason than
to have the backup and then be able to go home and
fire up your home machine, and be able to work in the Cloud. >> Absolutely. Also it's a lot
about collaboration, right? As we know, lot of
the largest open-source projects including Visual Studio Code, the innovation happened because of collaboration of
a lot of developers. >> Right. >> So at least within an enterprise, in the context of privately pose, you do want all your other colleagues to contribute to your
code base to innovate. >> I'm going to show that
like we call this the "Code workflow" in GitHub
and the pull requests. Before I go there, let me put
this to my GitHub repository. So here I go to my "GitHub tab", and as you can see it says, "This repository is
not yet on GitHub." So I'm going to push this, just
this window and let me close this, and I'm going to click
on "Get started." If you have not logged in before, it's going to prompt you to login. But since I've logged in, I don't have to do that. I'm going to click on
"Publish to GitHub." So at this point, I just pick
the account that I want to use. So you can see like I have
a few accounts and I have my personal free GitHub
public repositories, or I can choose my GitHub Enterprise. So I'm going to put this into
my Enterprise repository, and I'm going to publish this. So now my code is
published onto Github. >> If you have
two-factor authentication set up, you'd get notified. >> That's right. >> At this point, typically
I have to get my phone out. >> I use the Authenticator app
that's much easier perfect. So there you go. So a repository has been created. Now a developer, I mean others can go in and check out the code
and start working on it. I can show you that. Let me switch
to a different machine here. This is a Visual Studio
2019 again but on a different instead
of virtual machine. So I can show you if
I'm another developer, my colleague and then I can
go and check out the code. So I click on "Clone" at this time. I can specify if I know the URL or I simply click
on "Browse a repository". So it's going to go and fetch
that project that we just published. So I'm going to take that and it's
going to Git download the code. Remember this is distributed till all the code gets downloaded here. I specify where I
want to download it. I can choose wherever I want. Okay I'm going to just keep
the default and I'm going to say, "Clone". So that's it. So it gets cloned onto
my local repository and it opens the solution, and now I can start
making my changes. >> Right. >> So Sachin, we hear a lot
about pull request and branches. So what are branches and
what is the pull request? >> That's a great question.
So a big advantage to me like is
the codebook flow process. So when you make changes, often users create a feature branch, and keep those branch changes
isolated in those branches. When it is time and when you want
to notify others that you are ready to merge the changes
with the main branch, you create a pull request. So it's a way of
notifying others that, "Hey I have made some changes. Please take a look at my changes, and if you if you like it then you can pull this into the branch.". >> It's very little like peer review
also within the work flow. >> That is right. >> It's also a great way of if
you're letting other people contribute but you still want to
maintain control of the code. So you can make a pull
request on.Net for example, that doesn't mean your code's
going in automatically, the team will review it and
then talk to you about it. So that's a request, right? >> Yeah. >> Yeah. I like to call
it as a merger request. >> Yeah. >> Right. So that's why it's not a push request
but it's a pull request. I can decide what changes
comes into my branch. >> To a point Robert, yes someone needs to approve before
you can go ahead. >> Right. >> So let me show you
that. Okay. So let's assume that I'm going to build
another awesome feature. So I'm going to go to my
"Visual Studio" here and to the "Team Explorer" and
I'm going to create a branch. I'm going to create
a local branch first, so I'm going to click on "New
branch" and I'm going to call this, "My awesome feature." So I create this branch and I'm going to check
this out immediately. You can see if you've noticed
this and it was showing, master, now since I've checked out, it has changed to
this particular branch. Now all the changes that I do
here stays in this branch. So let me go and make a change. So let me go to my solution here. I'm going to open up a C# file. I'm not going to show
my coding skills here. I'm just going to make some changes. I'm going to make let's say, my awesome feature goes here. So I make this change, I save this, and I need
to check this in, right? So I haven't shown you this. So let me show you how
you do this checking, we call this process a note commit. So if I go and click my changes, I should see this and I
change this particular file, and if I open this one, I would see what exactly I changed. I'm going to check
this end of the message, add a new line and I'm going
to commit and push this. So when I do a commit, it
goes to my local repo, when I say commit and push, it's going to the local repo, and then it'll push into
the remote repository as well. So I say commit and push, it goes into the branch. >> Right. So that's another benefit
of it being distributed. You have your own copy, you can commit and work on it until you're ready to let
other people see your current skill. So you might be halfway in between, and you haven't figured out. It doesn't work yet, it's failing the test
on your machine. It doesn't do what
it's supposed to do. Only when you're ready, can you push and share with
others and then you as a team, can figure out what the policy is. How long can you keep something checked out before
you publish it, right? >> That's right. Yeah. You can
create Pull Request at any time, not just like when you are
ready to move those changes, but let say that you need help, you need advice from your colleagues on how do
we solves some problem. You know you could do that.
So here as you can see, it shows that I have
some changes in my branch, and I can create a Pull Request. I'm going to go and create a pull
request, and I'm going to say, I want to merge my changes
that I just created in my feature branch here
with my master branch. So I can put in a message and I
can say "Create pull requests." So now this goes to my team members who can come
and look at the changes. They can comment and
approve my changes. >> Probably you let some inner
loop desk chain and now you feel to share and get others
involved with reviewing your code. >> That is right. So if I
switch back to my other window, and if I go to my GitHub, I should see, let me refresh here. So I should see the Pull Request
that I just created. >> This is brand new in 2019. The ability to look at the poll requests and approve
them from inside Visual Studio. >> What I like about
it is [inaudible] >> In 2017, you had to
go to GitHub to do it, which is not terribly difficult, but again, it's a context switch. >> Exactly, you do a lot of
togging between applications. >> Right. >> Not just that. If
you are looking at changes that's not code related, it's easier to do it on
the web, but if it's code, I like to use Visual Studios because I can use all of
the navigational features. I can step into, I can look
into different things, so I can understand the context
and then I can approve or reject. >> Yes, your command center. >> Exactly. So let me
open this Pull Request. I can see this is
initiated by my colleague, and I should be able to
see the exact changes. So if I bring this up, again, I see the different door. I can see what was before
and what's the change, and as I said, if
you want to comment, you can come in and go
directly on the change here. So I could say like, hey, I like this change, I can put emojis, I could ask questions like, how about updating docs? I can, or maybe writing some code
that actually does something. >> Oh yeah. So I have
provided my comments, and this comment now goes
back to my colleague. He can let you know if
there's any action item. They can fix that first. When I'm done, I can
approve the changes. At this time, I have said, okay, the changes look
good and it can be merged. To do the emoji, you have
to go out to GitHub. >> Okay. >> Luckily, I have
view on GitHub here. So I'm going to bring this pop. So it should load this on my browser. It takes me to the pull request page. If I scroll a bit here, you can see that
the approval has been provided and now my changes can
be merged into the main branch. Click on this one and
my merging is done. >> Fantastic. So this is like
two robots earlier point. I can have a lot of my colleagues
start contributing. But yet that's self-control
and you still get to approve before code goes
into the master branch. >> Yeah, that increases the quality before you
come into your changes. >> Awesome. So that's
wonderful searching, like you showed how we
can upload our code, do commits, how to
create a new branch, do a pull request, merge the branches all without
leaving Visual Studio? >> Yes, that's right. We also have integration in OVD Azure Pipelines and Azure
boats that takes it even further. Right now, I can take my
code and those integrations, I can setup CICD pipelines and I can also relate my changes
into the backlog items. >> That's what Mickey was showing
in the previous episodes. So if people want to
see how to do that, they just have to go
back one episode. >> Got it. >> We got to did these
out of order, I guess. I didn't really think of it that way. We did pipelines and
then the week after, we did the source control,
but that's okay. >> Got it, and I guess we can
also track commits and pull request and associate
them with work items in Azure Boards which gives
full end-to-end [inaudible]. >> Yeah, and for Visual Studio users, I think you have even a better news. >> I know. >> You want to share this? >> Yeah, I'm happy
to announce that we have a new offering Visual Studio
with GitHub Enterprise, which is an easy and
economical way for Visual Studio users to
acquire GitHub Enterprise. So if you are a Visual Studio professional or a Visual
Studio Enterprise subscriber, you can upgrade to
this new offering and save money. You can find more details at
the aka.ms/VSwitchGithub. >> Fantastic. All right, so we've looked at
today quick overview of how easy it is to be using Git resource control from
inside Visual Studio. We'll put up some resources
where people can learn more. The docs are fantastic, I love saying that. The docs are fantastic, we'll have links to that and maybe it's just some
additional resources. As mentioned, it's free. It's easy to use, it's great stuff. Thanks so much for
coming on the show. >> Thank you so much
for having us here. >> Awesome, thanks a lot Robert. >> Hope the guys enjoyed
that and we will see you next time on Visual Studio Toolbox. [MUSIC]