How to Install Git on Windows 10 | Download, Install and Configure Git Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
there's a lot of things to love about git one of the things that I love is the fact that it's so easy to install there's no long list of prerequisites for git all you need is a modern operating system and by modern I mean like like Windows 10 is fine all you have to do is head over to a search engine and type in download git don't get fished the first link you get should be get scm.com downloads and there's the option to just download git I'm going to download git for Windows because I'm running Windows 10 here you'll get a couple of options is it 64-bit or 32-bit I'm pretty sure you're running on a 32-bit operating system and after you click it well it'll get downloaded and it's just an exe file and all you have to do to install git is just run it and really you can accept all the defaults you don't have to get too complicated and what to select now I've been working with Git since there were only two screens on the git installer where do you want to install it and finish there's a few more options these days and I'll point out a couple that might be interesting to you but honestly if you just want to get git installed quickly you can just click next next next next next next it will install and your life will be fine so here we are installing get with the gnu general public license you know this was built by the Linux Foundation Linus travoltz wanted to have their own source code management tool that could manage distributed Linux across the world and and they built it so really two great software products from linister volts it's Linux obviously and git now it actually where you want to install git install it wherever you want I don't care I actually install everything into underscore tools and then I don't like having uppercase letters in any path just because I've written so many scripts where that messes them up so I just put it in to see colon slash underscore tools slash get put it anywhere you want doesn't matter I know where it is I can find it life is good so number of options to select as I said just a few years ago I think there was like only one or two options when you installed git now there's a plethora you can just accept the defaults here it'll install get bash it'll install a nice little git GUI tool just accept the defaults and click next uh does it do you want a start menu folder that's up for you to decide I'm going to accept the defaults here as well now here is one setting that I would highly highly highly recommend you change especially if you're new to git when you have a merge conflict or something and you're using Git You have to provide some notes or when you do a commit you have to put in a commit message and git will bring up vim and Vim scares the life out of most new developers and seasoned developers like me I have spent a great deal of time trying to figure out how to exit Vim it's colon queue by the way I think it's colon queue anyways one of your options here is to replace Vim with something like notepad plus plus or just notepad on Windows I promise you your life will be so much easier if you change it to notepad or notepad plus plus because you won't have to fight a text based editor that it's very intimidating for people that are new to software development and it intimidates me I've been into software development for 20 years so I'm not going to choose it because I'm just going to choose the defaults here but that is my advice to you um it's going to ask you a little bit about whether you want to use the name master or Main it's a good idea to change this to main um if you're going to be working with a lot of old repositories you'll see the the the golden Branch the pristine Branch the master Branch named Master we are very much getting away from the verbiage of Master Slave terminology We Now call it the main branch you can call it whatever you want um if you're just having fun you can call it the golden branch Maine is kind of the vernacular today so I would suggest changing this to Maine now I'd also let you know that if you're using some continuous integration tools like Jenkins Jenkins actually looks for the name master so sometimes it throws it off but on the other hand the progressive people at GitHub if you create a new GitHub repository the name of the repository is main so I would make that change you can always change it back later too but leave that as Main do you want to adjust your path accept the defaults here so that git can work with third-party software real easily again another default you want to keep keep it bundled with open SSH if you want to do some SSH handshakes in order to secure your local connection to the remote GitHub server again accept the defaults use the openssl library accept the defaults what's the checkout style sometimes you can run into trouble if you know some people are using Unix other people are using Windows and you know some people use a forward slash others use a backslash in their folder names git will take care of managing the differences between platforms as you go back and forth so those issues go away so again do the checkout window style commit Unix style so that way your Unix developers and windows developers won't run into trouble so again just accepting the default use minty accept the default here it's asking how to merge Brands branches together um you can really streamline your git commit history if you allow git to do Fast Forward merges it flattens out the commit history when nothing very exciting is happening so that's a safe parameter to use as well also do you want to use git credential manager this can actually help keep track of your username and password when you're connecting to external services so again leave this alone here enable system caching why wouldn't you want some caching on that's fine avoid the experimental features for now and then just click install and boom all of a sudden git will get installed so there you go that's how easy it is to install git now once this is done I want to show you a couple of configuration settings that you have to do otherwise you could get in trouble when you do your first commit and I'd also just like to to show you how git actually does the key things that it does git really only does three things it can help you manage a commit history that makes it possible for you to save the state of your workspace save the state of what you've done so that you can go back to it if you really messed things up it's just like you know clicking save every once in a while as you're writing a Word document or something like that although I think word Auto saves git doesn't auto save yet it allows you to develop in branches and branches allow developers to do isolated developments so if they mess something up none of the other developers know and it also allows you to do collaborative work so it allows you to go to GitHub and pull changes down from GitHub and make some changes and push them back up but those are the only three things that it does manage a commit history allows people to do isolated development and branches and allows people to work collaboratively in a distributed environment around the world so those are the the really the three key things that git does and if you master those you've mastered git I've got a bunch of tutorials on how to do that but I'd like to show you some of the basics of it after we've done the install so do you want to launch git bash I'm going to say no for now but if you're going to be doing some work with Git you're probably going to want to get familiar with get bash we'll bring that up in just a second but I'm going to click finish there git comes up gives me some release notes that all looks good to me I'll close that window I don't know why Edge came up there because I thought I thought Chrome was my default browser but um there you go okay so what's next you've installed git how do you know it's installed well what you do is you work with Git a little bit and here's what I'd like to do I would like to just create a new theoretical workspace for creating an application creating some code it sounds like a big deal I'm just going to create a folder and put some files in it and then add a couple of files to get just show you how easy it is so I've got my C drive right here and I'm going to create a new folder on this C drive and I'm just going to call it underscore repos that's it so create a folder called it underscore repos life is good I'm going to go into that folder and I'm going to create another folder I'll call it my first repo I guess I probably could have just created a folder called my first repo but I always create a folder called repos on every computer I have and then I always get clone into that folder so um but I create a folder called repos to create another folder called my first repo and if you didn't guess it already I'm gonna create a git repository here a place where I can create files I can edit files you always associate git with code but it can be any type of file and I can have git keep a history of all of the files that I create so how do you do that well you can just right click on any folder and notice a couple of options have come up one option is open git bash here another one is open get GUI get gui's a great tool to help you work with Git it gives you point and click get functionality people that want to look you know really Advanced always open up the git bash shell bash Born Again shell you're not really supposed to say get bash shell because the sh stands for Shell it's equivalent of saying the get bash Shell Shell um but anyways I'm going to open up the get bash shell and that's opening it up in this folder and you can see the get bash shell says that I am in the my first repo folder now I am going to increase the font here so give me one moment to do that foreign so I've create opened up the git bash shell in a folder named my first repo and I'm going to create a git repository so I just do this I go get in it in it standing for initialization and it says Hey I just initialized a folder to be a git repo it even says I put a special folder in here called dot get and it's like no you didn't but it's actually a hidden folder so if I come over here and I say View options change folder options go in and say hey show all of those hidden files click apply click ok when I come back in here view options change folders show hidden files apply okay now we can actually see that dot get foldering it's a little opaque that means it's uh it's a hidden folder now you don't have any reason to go in there that is just git if you actually deleted that folder you'd be deleting this git repository I'm going to live dangerously I'm going to dig in there you can config hooks objects this is actually where git keeps your commit history keeps track of you know GitHub bitbucket get lab repositories you might be connecting to all of the configuration stuff is in there the history of all your commits as I said leave that folder alone but it's just gives you a good warm feeling to know that it's there now what do you do with Git well you know the idea is you just you know you start creating folders or create files right so I'm going to create a new file I'm going to call it Alpha Dot txt and I'm going to create a so a new file has been created one of the things you can do is you can say to git hey what do you what do you think about um my folder's there you see anything interesting there Ctrl L clears the screen and I'll say get give me the status on that current folder and git comes back and says hey there's a new file in here I'm not paying attention to it it's untracked if you want it to be included in a commit in the future tell me to to put it into my index of things to include in the future commit um and I'm good with that I could I want to make that part of a future commit so I'm going to add that to what they call the git index and the way you do that control L to clear my screen just say git add and then the name of the file alpha.txt and so now I've said to get I said you know I created a file the next time I do a commit I want this file to be part of the commit maybe you can create multiple files and then make them all part of a common commit um people say what exactly is a commit and I always say you know a commit's like a save point it's like you're playing a video game and you get so far in the video game and and you hit a save point and then you keep going and then you die well you don't have to start at the beginning you can go back to that save point and that's what a commit is like and get it's like a save point a point that you can always go back to the other cool thing is about these save points is you can share them with others you can push them to a GitHub git lab bitbucket repository and anybody else that uses that repository well they can pull them down and see your commit so you can share it with people too so that's the idea of a commit now here's the thing uh after you've added a bunch of files to the index you can do a commit but the very first time you do a commit if you don't configure your username and email address you're gonna get hit in the head with a hammer uh and that's because every time you do a commit you're supposed to tell get who you are and how somebody going through the repository could contact you and that's through your email address so every single commit you do get your name and your email address on it don't worry you're not getting added to a newsletter you're not going to get emails from git.org or linister valves it's just using the git repo and if you never move your repo off your local machine no one else would ever see the the username and password on there and you can just can just put a garbage not password email there's no password I just put a garbage email on there if you want I'll show you the issue right because like we're all excited and this is the funny thing about get I said there's lots to love about git the one thing I don't like about git is the first time you do a commit and you say hey get I want to do a commit right I want to create a save point Dash M says I want to add a message here and then in quotes I could say my first commit right and the double quotes now this is going to error out on me okay this is going to cause a problem and it's going to say I don't know who you are and I don't know your email address and you can't commit to this git repository until you've told me your username and email address so you have to do these I don't know I think these are fairly cryptic commands you got to do git config dash dash global global means you can do this just one time and then you don't have to do this every time you create a new git repository um you could do local configurations too thank you user.email and I'm just going to say you know me at example.com like it doesn't it doesn't go anywhere right I want to just avoid any fear that like you're going to get on some mailing list here and then get config dash dash Global user.name and my name is Cameron McKenzie I'm the editor-in-chief of the serverside.com uh head over to the serverside.com for lots of git tutorials I forgot to introduce myself earlier I hope you forgive me okay so now I've configured my email and my username now I can do a commit so git config uh so I can do a git commit if I click up if you click up in this tool enough times it'll take you back into your history I'm going to click control L um just to clear the screen a little bit there and I'm going to do my first git commit and boom there you go I gotta commit done now I'm going to create another file over here I'm going to create a new text document I'll call it beta Dot txt you know when you're working with Git You always think it's going to be an HTML file a python file a ruby file a Java file kotlin files like git can keep track of anything right like you want to maintain a source code history you know git can do it can track any files images stuff like that you don't want to put big files in your git repository generally but it can do it okay if I could do it I get status now notice they'll say hey again there's got a new file so that's beta I could also I could also go into Alpha and make an edit hello get world we just installed git on windows 11. okay now I'm going to click control L and do get status again and so now it's a little different it's saying hey you've got an untracked file a brand new file and you've got a modified file and none of these are going to be part of the next commit because you haven't added them to the staging index yet you haven't added them to the list of things you want to include in the next commit I'm going to click Ctrl Alda to clear that up but one of the things you can do to just add everything to a commit it's just say git add Dot and a DOT is kind of like you know everything in this folder in subfolder and now if I do that get status command it says you know you've staged two files nothing's untracked right now and if you do a commit the the fact that this the the the changes to Alpha will be included and as well the new file beta will be included so why not do that get commit M what is that second commit git status nothing to commit everything's done so there you go that gives you a you know an idea of how to work with Git that's how you do the basic configuration how you add files um so that kind of gives you a basic look at how you can manage the commit history now there's another cool tool here so you notice that if I right click there's also something called the get GUI tool and so I'm going to open up that git GUI tool and here it is it looks like it's in my first repo over there so there's the get GUI tool now look at this I'm going to create a new file over here a new text document I'm going to call it Charlie Dot txt let's see come over here jeez I thought that uh it would have found that file Maybe I have to rescan and as soon as I rescan now the get GUI tool is saying to me hey you've got some unstaged changes and it's like oh do I was like yeah okay let's add those to the index so you double click and it now stages that file so this is doing the same thing as the get add command that I did before and it says you have a kimit message I'll say this is the third commit right click the good old commit button and it says hey you now have three commits in your history so this is the get GUI tool and it allows you to do all of those neat things that uh you can do with the command line I think most of the things you knew the command line certainly all the get porcelain all of the high level commands that people use in git is referred to as the porcelain and then there's like really low level stuff they call that the plumbing um but that basically you know gives you a a nice tool for doing all the major things you need to do with Git there's also this cool visualize history so if I could say visualize is Maine's history you'll end up getting this nice tool that comes up here and you can see it's actually giving me a little visualization of the history you can see those three commits even gives me the commit ID of each of these commits here just a I really can see the email and username of the person that did the commit that's why you do that git config that's just a real nice tool that allows you to to view the history once you start getting into a lot of merges and a lot of commits uh you can end up having a really rich commit history so that's pretty cool now after you've done that you know one of the other things that you might want to do is you know just maybe clone something from GitHub right like if you're using this tool you're probably working with GitHub so I'm going to go to github.com cameronmcnz and let's see if I've got any repos up here looks like I got a number of handsome ones and one of those reposes is a Spock lizard Docker repo how could you not clone that so this is a repository that I've got up on GitHub it's a public repository anybody can see it and if you join a team it's very very likely that they'll say to you hey you know the code for the applications up on GitHub why don't you pull it into eclipse or pull it into vs code or IntelliJ or whatever IDE you're using or even just pull it down onto your local file system and when you take code that's up on the server and bring it down that's called a clone when you create your own repository that's an initialization if you pull code from GitHub gitlab code commit that's called cloning but in order to clone a remote repository you need the remote repositories URL and so if you click the beautiful green button there you actually get the URL of the remote repository so you can see um you know github.com cameronmcnz sparklizard Docker I would just say copy that now my copy and paste skills are horrible um so I'm going to like copy that a million times I'm going to click that super hard I don't know why my copy and paste it always messes up and what I'm going to do is I'm going to clone that repository right so I'm going to take that repository you can see it's got cool files on it like Jenkins file Docker file this dot HTML palm and it's got a source file with all sorts of crazy Java code in it I'm just going to take that that URL from that green link and I'm going to head over here I'm going to close my git GUI tool I love git GUI but I'm going to close that up by the way I got a couple of tutorials online about some other git tools as well there's get Kraken there's Source tree GitHub desktop is another really really popular one so I always recommend people it's good to know the command line but at the same time it's also really good to to have a tool that can simplify a lot of the git stuff for you now I'm back in that repos folder I'm not in the my first repo folder right that's already a git repository you see that dot get there but the the repos folder is just a folder that can contain other things and what I'm going to do here because I'm going to open up that git bash shell and I'm going to issue a clone command I'm going to type in git clone and then I'm going to paste as I issue this I want you actually to look in that repos folder right there so I'll move this over just a tiny bit and as I do this you'll see a new folder get created you'll see that Spock wizard folder get created on that file system there so I'm going to click enter so it's cloning into Spock lizard docker it's a big repository so it might take a minute or two okay so it says it's done I'm going to close that window there you see that the Spock lizard Docker project has been cloned and now it is down on my file system so that repository that application that was up on Docker hub that Docker Hub up on GitHub boy we're getting ahead of ourselves Docker stuff and take a look at the files in here yeah and there we see up on the server we see files like Docker file Jenkins file declarative pipeline Maven Palm this.html SRC Target Walmart no sorry there's no Walmart their only target um and it matches all the files on my file system so now I've taken that code from the remote server and I've pulled all of that code down now the other cool thing is you can see that there's a a bunch of branches on the server and there's patch one what's that one down at the bottom there I can't even see it um you can always you know um switch branches when you are working with Git and uh I'm going to open up a gitbash shell here I'm going to move this a little bit so that we can see the the folder system but I'm going to go I'm going to type in git branch Dash a that tells me all of the different branches that are part of this repository a branch is a place where you can do isolated development take chances do things on your own boy that is a a lot of branches there Ctrl L to okay now I see I'm stuck in VI um I can't get out of here I'm clicking enter I can't get a lot of colon and then Q and now it gets me out always messes me up um but yeah so this shows you like all of the the branches here now I that's like too many branches but um you can see that there's a branch called Master there's a branch called prf I'm on Manchester right now um I could switch to that test Branch so I could say get switch test and boom now I've switched to another Branch but you'll notice that all the files on the right hand side there change as I move from one branch to another branches as I said are places where developers can do things and take chances and experiment and break things and if what a developer does on a particular Branch fails doesn't work well they can just delete the branch right and if they do something that they like they can merge that Branch into the main branch or the master Branch so if they like what they accomplish they can share with people so it just encourages people to test take chances things like that so for example I'm on this branch called test you can see the name there test so I'm on this Branch test and I'm going to create a new file I'm going to call install git on Windows 11. I'll just call install git on Windows okay so I've just added a file to this repository which is in the branch test and I can say git add just like normal and I can do git commit Dash m and I'll call it the install git on Windows 11. commit I don't know that's a long name but now I've made a commit and I've now got this file installed git on windows.txt as part of this Branch now watch if I do a git switch and go back to master now notice this was pulled down from GitHub that's why this one has a master branch and not a main branch but watch if I switch back to master which is what I cloned down you'll see that install good on windows.txt file goes away see so now I'm a master branch and that file disappears if I go back to the test Branch get switch test it's like I'm David Copperfield all of a sudden that file comes back and so this is one of the things that that branching allows you to do it allows developers to work in an isolated space and take chances write code maybe break the build and if what they do they don't like well they can delete it and if what they do they do like they can actually merge it back into the master Branch so I could do a git switch back onto master now I'm on the master branch and I can say git merge test and so you notice that on the master Branch over there we don't have that install git on Windows txt File but if now if I merge that test folder into Master it would come in now um just as I'm doing this I'm thinking this is a very bad idea because I have no idea how out of sync that test branch is with the master Branch because I haven't touched this repository for a long time so uh if things are really badly out of sync you can get a merge conflict and it's way too early in the morning to be dealing with merge conflicts but if everything worked out you could do a merge and that would bring the the to file to files together and of course it's not get merged it'll be git merge I spelled it g-e-t get merge task and it would bring them all together okay and so again here this is in VI if you weren't in VI if you were smart and you actually used a notepad as an editor you would be fine but right here I've got to actually go in here and type something in for my commit message and I said you know oh you know looks good wanted the install get on Windows File whatever and then to get out of here you just click Escape colon X hit enter and then your files are merged and you'll notice that now I'm on the master branch and I've actually got the install git on Windows txt File sitting right there for me so you can see that I've actually merged things together the other cool thing you can do after a merge is you can go into the get GUI and say Repository visualize all Branch history and it'll actually show you the point where master and test got merged together so you can kind of see that merge point in there but this will actually go through an entire commit history and for some repositories this can be pretty impressive so this kind of looks a little bit like the Paris subway system at a few points in here so that's all super cool um but yeah and and there you go so I mean if you think about it what do we do we installed git uh we installed git on Windows 11 then we did some configuration we configured our username and our email address we added files to the index and then we did a commit after doing the commit well we opened get GUI looked at the commit history then we thought hey you know really you know it's not just about a commit history book doing collaborative stuff like pulling from remote repository so we cloned a remote repository and then in that remote repository we actually did some work locally and now by the way that install git on Windows is local but if I was actually to go over to GitHub and looked at the files on GitHub you notice that GitHub doesn't have the install git on windows so everything that I've done so far in this repository clone is all local in order to get these changes up to GitHub and share them with other people I would have to take those files and push them up to GitHub and then after you've cloned something for the first time you want to get changes and bring them down you have to do a pull or a fetch pushing to GitHub would require some credentials so I don't want to get into that but um and I'd have to log into GitHub here in order to add some files I think that's all some stuff you can cover in some future courses but I mean we covered a lot of the basics here even taking a look at branches and how we can create code and isolated branches and merge branches together so I think overall that's a pretty good look at how git Works especially considering you you may only just watch this video because you simply wanted to download install git on Windows 10 and get things working anyways before we depart I just wanted to mention a couple of things first of all I mentioned earlier my name is Cameron McKenzie I'm the editor-in-chief over at the serversite.com we've got lots of great tutorials on get devops Maven Jenkins Java python JavaScript no agile scrum you name it so head over there take a look at what we're writing about over on the serverside.com also I'm an author with a couple of books I wrote Pickering is Springfield it's all about how the town of Springfield and The Simpsons is actually based on a small town in Ontario called Pickering just outside of Toronto so for example the highway that goes through Pickering is the 401 the highway that goes through the Simpsons the Springfield and The Simpsons that's the 401 too which is weird because American cities don't usually have 400 highways they have interstates so check that book out Pickering of Springfield also I'm a job guy so I wrote a book called hibernate Made Easy all about hibernate and jpa check that out too might have some books on git and spring coming out in the future and I also I've been working with a young freelancer over on the server side may have seen her on Twitter she's got about 300 000 followers at scrumptuous on Twitter she wrote this great scrum Master certification guide and if you're interested in scrum if you want to be agile and maybe you want to advance your career and get a product owner scrum Master credential I can't recommend this book enough so I head over to Amazon and pick that up if you're interested in my personal Antics I'm on Twitter as well at cameronmcnz is my handle that's my handle on GitHub as well um and uh I think that's also my handle on YouTube and you know I'm gonna do the standard grovel where I ask you to so subscribe on my YouTube channel
Info
Channel: Cameron McKenzie
Views: 9,667
Rating: undefined out of 5
Keywords: cameronmcnz, theserverside, java, jakarta, jakartaee, git, github, gitlab, dvcs, versioncontrol, tortoisegit, gitgui, atlassian, bitbucket, linux, azure, devops, devopstools, gitops, gitopstools, azuredevops, gitkraken, codecommit
Id: 9CAwvKiLICs
Channel Id: undefined
Length: 36min 25sec (2185 seconds)
Published: Tue Sep 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.