GIT and Visual Studio with Azure DevOps Repos - Step by Step

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi welcome to the azure devops repos with git and visual studio for developers course in this course you're going to learn a ton of stuff you're going to create a project in visual studio push it to azure devops repos create branches learn about commits synchronization branch policies merge conflict and so much more i hope you will enjoy this course so let's get started so what is azure devops for any software project we need three things every software project needs a project management tool so what exactly is a project management tool a project management tool is where you gather the requirements break it up into various tasks assign it to people and make sure that they are doing the task so every software project needs a project management tool every software project needs a source control tool so what exactly source control source controllers when multiple developers need to work on the same code they will put the code in one central server and the developers will create the code and push that code to that central server so here you can see that there will be like a central server a code repository and the developers working in the local computers will create the code and will push the code to the central server the central server will maintain a history of all the changes so every software project needs a source control tool every software project needs a built-in deployment tool so what exactly is a build and deployment tool creating a software project is like putting together a puzzle every developer creates one piece of the puzzle so the build and deployment tool what it will do is it will take all the changes by these developers make sure that they all work well with each other and then once it works it will build them together and deploy it to the server and which in turn will serve the software to the end users so every software project needs a project management tool a source control tool and a build and deployment tool azure devops is like a three-in-one tool by microsoft so what exactly is tfs and vsds tfs or team foundation server by microsoft used to be the tool which did all these three things project management source control and build and deployment but it was an on-premise installation that means you need to install the software in your company and then you manage that particular software then as cloud became more famous the cloud version of tfs used to be called vsts or visual studio team services and then later on microsoft changed the name of vsds to azure devops so azure devops is this three-in-one tool it does project management where it gathers the requirement breaks up into tasks and assign it to people and monitors the progress the source control where multiple developers can work on the same code and build and deployment tool where all the changes are combined together and make sure that they work well with each other and deployed to the server in azure devops the project management tool is called azure boards the source control tool is called azure repos and the build and deployment tool is called the azure pipelines or cicd which stands for continuous integration and continuous delivery in this class we are going to learn about azure repos the source control part of it there is already a course on project management called azure boards and i have it published at patrickvideos.com as well as on udemy on udemy if you search for azure devops project management you will get the azure boards class where you will learn about project management where does git fit into this what is git now previously source control used to be in this one central repository either the cloud or your on-premise server so all the developers will create the code and save the code in the central repository this central server will maintain a history of who made what changes over a period of time people felt like we wish we had our own local version control like having version control in the central server is fine but we wish we had our own local version control so local version control is what you call git so git maintains a history of changes locally as well as we will use these azure devops to maintain a history of who made what changes remotely in the cloud so git is local version control too so let's get started first to use git let us go and install git go to google and search for get and go to this git downloads download the windows version do you want to install it say yes now before installing it make sure that visual studio is closed and once visual studio is closed click on next and keep clicking next you don't have to select anything keep all the defaults keep clicking next and then click on install now once you have installed git we now need an azure devops account so to create an azure devops account if your company already has an azure devops account you can use it or if you're trying to learn azure devops let us go create an outlook account and using an outlook account let us create a free azure devops account to create an outlook account just go to outlook.com and then create an account once you have your outlook account let's search for azure devops and let's go to the azure devops server over here you can either sign in if you already have an account with azure devops you can sign in or you can have a free trial click continue now that you have logged into azure devops click on the upper left hand side corner called azure devops and you will notice that you can create a project now this project is nothing but a project space your company may already give you the space or we can create one right here i'm just going to call it training space here i'm going to select private that means only people whom i invite can come and work on this particular space if i make it public like for example i want to collaborate with people over the internet then i can make it public but in our case most of the time it's going to be private the version control is going to be get and work item process is going to be scrum once you have this click on create project there is an error we can go back home but it has created the training space if you want to create another space you can always go to azure devops click on create new project and create a new project now if you go to this training space over here you will notice on the left hand side the things we talked about azure boards is the place where you create your requirements your user stories and you break it up into various tasks and assign it to people i have covered this in the azure devops project management course if you go to udemy and search for azure devops project management you will see my course right here so here you have repos repos is what we are going to learn in this particular course this is our source control and pipelines is our ci cd process so we are going to learn about repos so let's click on azure devops training space so this is our url copy this particular url because we are going to connect to this url in our visual studio the local computers are going to connect to this particular training space our azure devops training space our local computer is going to connect to the azure devops training space located here now let us open up visual studio and let us create a project in visual studio i'm going to click on file new project you can create any project i'm going to select asp.net code web application the reason is it will come with certain files that we can play around with click next i'm going to call it patrick videos project and i'm going to click on create here i'm going to select the web application and click on create so we now have a project in our local computer so you can see that in our local computer we have created a project called patrick videos project in visual studio the solution explorer is the window to our local project if you want to see the files in our local project you have to look at the solution explorer window just like we have a solution explorer we have another window called team explorer you can click on view team explorer and team explorer is the window to our cloud or the tfs server in our case it's going to be the cloud azure devops cloud now to connect our team explorer to the azure devops cloud click on this button over here manage connections click on manage connections and click on connect to a project if you are not able to see these things click on the drop down box over here and click on project and my teams and click on manage connections and click on connect to a project you should be able to click on connect to a project and come to a screen like this if you have signed in using some other id and you want to remove that particular id you can come here to the upper right hand side corner account settings remove the previous id close this and once again click on manage connections and you can sign in with your new id where you have the free azure devops account sign in so once you have connected to the project you will notice your space available over here click on your space you don't have to click on the project click on the space it by default created a project for you but that's not required and now click on connect if you have clone over here click on the drop down and select connect if you select this it will tell you to clone but we don't have to clone we just need to connect to this particular training space just make sure that you connect to this training space now let's click on connect once you clicked on connect this team explorer is connected to the azure devops space let's go back to solution explorer and right click on the solution do not right click on the project we want to put our entire solution in the cloud so right click on the solution and click on add solution to source control now if you are not able to see the add solution to source control over here then click on add to source control over here and then click on git the newer versions of visual studio have the add to source control over here and then click on git once you do that you're going to see something called as an up arrow and number two now click on this up arrow and number two right below at the bottom right hand side of your screen click on this up arrow number two and over here click on publish git repo now make sure that your user id is over here your organization that is the free account that we had it's right here click on advanced and here select the project call training space that we created so if you are connecting to your organization they would give you all this information which url and which project you need to connect to so once again make sure your email address is correct your organization url is correct and the project name is correct click on publish repository so here it will show that patrick video's project was pushed to that particular space so what we did is we took this patrick videos project and we pushed it to the microsoft cloud so what we did is we took this particular local project and pushed it to the microsoft cloud so how can you verify you can go over here and click on see it on the web if you click on this it will directly take you to that particular project repost files so whatever files you had this is your project so you can see in visual studio solution explorer you can see the controller models views the program the startup all these files are now on the cloud if you are not able to see it click on repos click on the drop down box your project should be right here patrick videos project should be right here now if for any reason this does not work that means you are behind a firewall if you are behind a firewall you have to set up the proxy server so look at the troubleshooting section where i have shown you how to configure git for your proxy server once you have set up the proxy server and git this should work fine if you're using the latest update to visual studio if you right click on the solution you will see something called as create git repository you can either click on this or you can click on add to source control git over here so i'm going to click on create git repository by right clicking on the solution since we are going to use azure devops let me click on existing remote and we need to give the location of our remote repository to find the location of our remote repository make sure you go to repost and over here select the repository name that is our training space name you should see a link like this this is our remote repository location you can click on copy now if you are not able to see this if you already have a project over here then you can simply clone this project or you can drop down and click on new repository and create a new repository like this make sure to remove the add readme and click on create and you will see that link appearing over here since we will learn about cloning a repository later on i suggest you either create a new repo over here to get this link or if your training space has a link like this in the repos then copy this link so i have copied the link from the training space repo so let's go over here and paste it and click on create and push so this will create a repository not only in our local git it will also push the repository to the remote branch so once that is done to verify if this project has gone to the remote repository to the cloud you go over here and click on repos again you should be able to see your project that you just created right here if you go to branches you should be able to see the master branch over here which will have the code that you just pushed now for the rest of the course whenever i refer to team explorer make sure you go to git changes in the latest update of visual studio they have moved the menus around so you should be able to see most of them in git changes if you are not able to see git changes click on view get changes you can also click on view git repository so this will show you the list of branches that are available as well as the history of those branches and for the rest of the menu items in team explorer they are moved to this git menu over here so you should be able to follow along just remember whenever i refer to the team explorer window you should be able to see them either in git changes or in git repository or in the git menu over here now if you are working in a corporate environment and you are behind a proxy server this wouldn't have worked so how do you troubleshoot now go open up git bash you can go search for git bash and over here type in these following commands you don't have to change the directory just type in wherever it points to so type in git config this iphone iphone global space user dot name and put in your name your first name and last name and then git config hyphen iphone global space user dot email and put in the email address and press enter so once you create this see where exactly this git bash file is pointing to here in my case it is pointing to c users battery in your case it may point to whatever your default location is wherever git was installed in your case it may be pointing to some other directory but go to this directory over here so in my case it was c users battery and you will notice that a dot git config file would have been created open this with notepad and you will see something like this i'm going to bring this to the left and save so this would be your name and this would be your company email address and if you are behind a proxy server you need to make some other entry over here too so here you can see that if you have a proxy server below your name and email you also need to make an entry for http ssl version make sure you keep the same syntax is equal to tl sv 1.0 or if you have another version of your tlsv you can specify that and for the proxy you enter whatever your proxy server url over here if you don't know your proxy server url ask your corporate admin or you can go to your internet explorer and in the settings you should be able to find out what your proxy url is in our case we don't need this i'm going to delete it so you will use this only if you are connecting to azure devops using your corporate proxy server if you are behind a firewall so i'm going to remove this and save this so once your proxy is set up you can try and add the solution and try to push it again and it should work fine now that we have our project in the cloud the first thing we need to do is we have to make sure that we give access to this project to our team members so to do that in reports go to your project and in the drop down click on manage repositories and in here click on security click on members and here you can specify who are the members of your team for example you can say that some of them will be like contributors i can add the members right here who are contributors and some of them may be like project admins or build admins so i can go over here and add them as project admins or build admins so let's add someone as a contributor you can either directly add the names over here or you can create teams you can go to teams create a team add people to this particular team like i'm going to say so here i have added another email address to this team and i can come to security and i can specify that the people in the team are contributors and this person alone is the project admin and like this i can go and give permission to this particular training space so these permissions are applicable to all the projects in the training space now that we have given permission next let us look at branches by default git will create a master branch for you you can take a look at the branch over here in branches or in visual studio you can click on branches if you are not able to see this menu always go to team explorer click on the home button and click on branches and in team explorer you can see that it has a master branch both locally as well as in remote so master branches are created by default remember we should never work on the master branch you should always create another branch and work on it so according to git whenever you're going to work on a user story or a feature you should create a branch you can create as many branches as you want you don't have to worry about space constraint imagine you have one gigabyte of code and if you create a branch it doesn't mean that there will now be like two gigabytes of code no version controlling software are so intelligent that when you create a branch it will only store the differences in those branches so if you have one gigabyte of code if you create a branch it'll only be like one gigabyte and like say a few kilobytes so do not be afraid of creating multiple branches branches do not take up a lot of space so now let's go create a branch for something that we are going to work on you can either create a branch here locally and then push it to the remote or you can create a branch remotely and then pull it to the local we will see both ways first let us go create a branch locally and then push it to the remote so to create a local branch like for example we are going to work on some user story i want to create a branch right click on the master branch this is the local master right click on the local master and click on new local branch from and here let us give a name for the branch i'm going to call this let's call this branch user underscore story underscore 0 1. let's keep the check mark here at the checkout branch and click on create branch so now you can see that a new branch called user story o1 has been created and it has been checked out so if you go work on the solution explorer right now we will be working on the local branch called user story o1 now let's look at the diagrammatic representation of what just happened so here you can see that when we first created the project it created a master branch in the local computer so it created a master branch in our local gate and it also created a master branch in the cloud it created a master branch in the cloud so this is the cloud master branch which has the code you can click on the master so this is the cloud master branch if you want to see the code in the cloud master branch go click on the master and you will see the code over here this is the master branch code that we have then we right clicked on the master and created a new branch we said write new local branch from in the master and we checked it out and that creates a branch in the local computer in our local git so here you can see that we have created a new branch and this branch is going to be like user story one so we have now created a branch from the local master called user story o1 now if you want other people to work on the same branch then what you need to do is you need to push this branch to the remote you need to push this branch to the remote if you do not intend to share this branch with other people if you feel like you're the only person who's going to work on this branch then you don't have to worry about pushing it to the remote you can work on this branch you can go here this has already been checked out and the way you know that this has been checked out is you can see that this branch is bold if you want to go back to the master branch you can double click on the master branch so whichever is bold that means that particular branch has been checked out that means when you make some changes that code is going to be changed in that branch you should never change the code in the master branch always work on the local branch now imagine other people also want to work on this particular user story or one branch then to push it to the remote right click on your branch and click on push branch when you click on push branch it will successfully push the branch to the remote and you can see that over here it's available in remote origin you can also go and verify it by clicking on branches here in your cloud so you can see that the user story o1 branch is available in the cloud too it's available in the cloud and other people if they want to work on this branch they can work on this branch how will they download this branch we will see that later now that we have created the user story and pushed it to the cloud let us go work on this user story let me go to the solution explorer and make some changes i'm going to make some changes in the program classifier so in the program.cs i'm making some changes i'm putting in a comment the first thing you'll notice is whenever you make a change there will be a check mark right next to that particular class file so let me make a change in startup.cs i'm making the same statement make some changes over one let me go create a test file right click on the project add class so i've added a class called test file since it's a new file you can see that there is a plus sign right next to it so like this i'm making some changes when you make some changes to your application there are three places you need to save these changes so here is your diagrammatic representation you have your local master and local branch and then you have your remote master and the remote branch the three places that you need to save your changes are first you need to save it to the local hard disk the way you save changes to your local hard disk is pretty simple you click on file save or you click on this floppy disk so here i'm going to click on save all so this saves it to the local hard disk the second is saving to your local branch so let's learn how to go save it to the local branch so here go to the team explorer home button click on changes and here it will show you all the changes that you have made so you change the program dots here startup.cs and you have added a test file to save changes to the local branch first we need to give some kind of a message i'm going to say make changes one and here you will notice that there are three choices commit all commit all and push commit all and sync if you press on commit all it will save your changes to the local branch if you press commit all it will save your changes to the local branch the second choice if you say commit all and push the second choice if you say commit all and push what would happen is it will save it to the local branch and push the changes to the remote branch we also have the third choice commit all and sync what does commit all and sync mean commit all and sync will first save the changes to the local branch then it will pull the changes from the remote branch into the local branch and then it will push the changes from the local branch into the remote branch so basically sync means it's a pull and then it's a push now if you're working in a team environment and there are other developers working on the remote branch then it is always recommended to do a commit all in sync i would never recommend you do commit hole and push because if you do commit all and push there is going to be a problem of merge conflict you may be changing files that some other developer changed in the remote location so when you do commit all and sync what will happen is it will first save it to the local branch then it will pull the changes of other developers in the remote branch to your local branch so if ever there is any kind of problem if there is a merge conflict we will see about merge conflicts later on but if there is any issue while updating the code from the remote to the local then we will be able to fix it right here so either do commit all or do commit all and sync in your projects first let me do the commit all so now that i have committed the file we know that it is there in the local branch the changes are there in the local branch we can go verify that by looking at the history of the local branch you can go home click on branches right click on user story 01 and click on view history when you click on view history you can see that there is a commit to the local branch you can see how the files have changed by selecting two comments by keeping the control key pressed select one and select another commit right click and click on compare comments and you can see that three files have changed you can go double click on program.cs it will show you how the files have changed how startup.cs has changed and test is a new file so using the history we can see how the files have changed now that we have committed to the local branch imagine you want to push the changes to the remote branch now in the cloud if you notice repost branches if i go to user story or 1 you will notice that there is no test.cs and the program.cs or startup.cs does not have our changes imagine i want to push our changes to the remote branch so how do i do that you can go home over here click on sync sync basically doesn't sync up immediately it takes you to that sync menu and over here you can see that there is one outgoing commit still left because this hasn't been pushed to the remote so over here you can either click on push this will push the changes to the remote branch or as i said i would always prefer you click on sync when you click on sync it will first pull the changes from the remote branch into the local branch and then it will push it of course if you're the only person working on this branch in the remote or locally it doesn't really matter you don't have to sync it but it doesn't harm you in syncing it so i'm going to click on sync now that i have synced it it has pushed the data from the local branch into the remote branch we can go verify that if i go to branches user story one and you can see that there is a test.cs and the program.cs we have these changes right now let me go back to the solution explorer and make some more changes i'm going to say make changes o2 make changes or two so i made changes to the program and startup let me go to the team explorer home the first thing you go is changes you have to give some kind of a comment about what changes you made in some teams they may insist that you add a work item this is like if you already have a user story id you have to specify them over here but we will learn this later on and you can see that these are the two files that we are going to commit now instead of saying come at all i'm going to simply say come at all and sync so this way i don't have to first save it to my local branch and then sync it up with the remote branch this does everything in one go so i'm going to simply say comment all and sync and it would have synced up with the remote branch so i can go verify the changes i can go to branches view history of this branch and you can see that it has been committed over here locally and remotely i can go to the cloud of course once again you have to click on branches that's the only way to refresh this click on user story or one and if i go to program.cs you can see that we have some changes or two over here you can also see the history of all the comments in the remote repository click on history over here and you can see how the changes have been made in the remote branch
Info
Channel: Patrick WashingtonDC
Views: 13,663
Rating: 4.860465 out of 5
Keywords: Azure DevOps Repos, GIT, Azure GIT, Azure Repos GIT, Azure Repos, Azure DevOps GIT Visual Studio
Id: DGOnvqNC9sw
Channel Id: undefined
Length: 35min 22sec (2122 seconds)
Published: Mon Jan 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.