Hi Guys, I want to let you know what this video is going to be about. Its about GitHub
and Visual Studio, its not a GitHub or Visual Studio tutorial, its about using the two together.
So I expect that you already have Visual Studio and GitHub experience.
I haven't found a compressive video on this which is why I put this up.
The first thing to explain is Visual Studio tools for Git. When you are going through
this process, at some point you may be prompted to install this. If that happens then just
go ahead and do that.
Next I want to create a local folder here called GitHub. So this is a fresh environment
we are going to setup and everything is completely new as if we set up everything for the first
time. This folder is where all our GitHub files will be stored.
Next I want to explain how to create a git repo. I wont go through the details of how
to create a git repo. We will just call ours ABC, initialise it with a readme and also
add a git.ignore file for C# because that is what we are using here. This will add 2
files to the online repo. We will come back to this later.
Next we will open up visual studio. Again everything is new. So we will click View and
Team explorer which will bring the Team Explorer window up. Just ignore this for the moment
and we can go to the home screen.
So this is the home screen, and the reason for coming here is because we want to see
our settings. So click on Settings and Git Settings then setup your username to whatever
you want. This does not have to be your GitHub user name as it is only used for commits.
So I will just put my GitHub user name here. Also I will put my real name. Then I will
put my email address. It doesn't matter what you put in here, its not validated in any
way, and its not used for anything other than git comments. I can put anything I want even
a totally invalid email to show it is not validated in any way. All of this is only
used for git comments so don't worry about it too much.
One of the main issues you will run into if like me you use a network machine at home,
I have all my dev stuff put on a server so but you cannot access server locations with
this tool at the moment. They are working on resolving that but just to be aware of
it. This is the reason we setup that folder earlier. So I am going to just pick the local
folder I setup earlier because we cant use a network location, we must use a local folder.
So once all that is done just update our changes and that's it.
Next we go back to our home screen to move on to explaining what it is all about. First
we have our home screen, then our connections, then changes and these are the three things
we are going to use a lot of. We will also go into unsynced commits in a few minutes
and we are going to cover all that here shortly.
Next we go into connect to team projects. That brings up the screen we had at the start.
Next we are going to work on creating a clone. Do you remember earlier we create a repo in
GitHub? We are going to clone that repo down. You can go through this whole new process
but it does not create a repo for you so your still going to be required to do that anyway
towards the end of this process. So that's why I created that repo at the start. So we
are just going to clone this down.
This brings us to the next issue we come across. Visual Studio doesn't use SSH, it uses HTTPS.
Its something they are working on and may fix later. Just to be aware of it. So just
HTTPS link for now. So copy and past that in there. Before I did that it gave you the
folder automatically and also note the comment in the empty box. Once you put in the link
in this box it will automatically rename the folder for you. So just press clone and it
pulls it down to your local machine.
That is the process for cloning any repository that you want to work on in any git repository.
Once its cloned, it opened the repository automatically because it was the only or last
one we worked on. So you might have a list of them. As this is our first time, we only
have one. If you want to open one, just double click on it and away you go.
Next we are going to create a solution inside this repo. However before we go there, I just
want explain what happened so far.
We created the repo earlier and put the two files in it. There was nothing in the GitHub
directory. But then when we done the clone process, it cloned down the repository and
various files in it to our local machine.
Next we will add a new blank solution to this repo. We will just turn off the add to source
control option because that was what we just did earlier. You can double click n the solution
if you need to but it's already open. Next we will just going to add a new HTML page
called index.htm with the phrase "Hello humpty dumpty".
Like all good programmers, you should be in the habit of running your code before committing
it. The first time everything runs in Visual Studio its always slow but then it gets faster.
So our program is working and everything is going great.
We have all these wonderful new files so we are going to go back to our Team Explorer
and look for our changes. So we click on changes here, and we have all these included changes
that we want to include in our commit to start with. So we can exclude any of these files,
just by right clicking and pressing exclude. We can also include them by right clicking
and pressing include. We can also include all, exclude all, and we can do all these
straight forward things.
We want to put in a commit message. Then we commit these changes. So this commits to our
local machine. And what you'll see is our application, and index file is all there
locally. But its not yet on our GitHub repository. Even if we refresh its not there because we
have not pushed it.
Next we see a bit of language that is not used in standard git or GitHub. This is Sync.
What this will do is bring us to the untracked changes. If I press sync now it will do something
but I am not going to explain what that's about because it's not normal language for
git. So if your going to use a tool, you should commit to them fully and use the proper terms.
So I am going into unsynced commits which is where we just were. This is our information
that we setup in the settings showing the various comment details along with the hello
message that we just typed in. This is how it tracks who commits what and when. So that's
what those settings were for at the start.
Now I'm going to explain some best practices for using source control. The first best practice
is: Dont break the build - So whatever goes up here, other people are going to be downloading
it. You don't want them downloading something that is broken because then have to fix it
before they can run and test their own code. So this is not practical. So this should be
a rule to follow, which is not to break that build.
Always before you push you should pull down. That just pulls the other peoples work down
to your local machine first. If there is any problems you can resolve them locally and
if it takes some time, pull again, it doesn't do any harm to keep pulling until you resolve
all the problems. When you are finally ready you can then push up to the server. Once you
push up and we refresh the page. You will see your solution has gone up. So there it
is and we can explore and see our files.
So that's just how it all works. Remember, not to break the build, pull before you push,
and only push working code. Those last two will generally prevent you from breaking the
build.
Thanks for watching the video, I hope you find it useful. Bye Bye.