 Today I'm going to be setting up a Git server. I've done this before and I recently switched servers So I needed to set it up again. So I figured I'll show you how it you know How you do it? I'll probably have to break this up in two videos because I really want to do two things one is I want to have a Git server so you know although I use github and gitlab theoretically I have something on my own Website where I keep everything and I basically push you know when I make changes to any repository push them to all websites Additionally once I do that. I also want to have a html website that looks something like this. So this is suckless is git Repository and it has this web front-end Where you have you see all the repositories you can click on all of them you can see individual commits things they do You know, I've had this before on my website I actually had a style sheet that I like more than what they have but in general it auto generates all the stuff for you So I'll probably do I'll probably have to break this up into two videos, but I'll go through it pretty quick so The first thing I'm gonna do or I will say there's one other thing before we start and that is You know, I so my website obviously is Luke Smith dot XYZ I want my git server to be a git dot Luke Smith dot XYZ. That's where it used to be In fact, you can click on my old Git link and it says oh there's nothing there or at least it's not private It's trying to redirect to SSL. We'll we'll take care of all this But the one thing you need If you are doing like I'm doing and you want to put it at git dot Luke Smith or git dot your name Whatever is you want to make sure on your domain registrar you have a C name record that redirects git And if you want www.git to your own website with of course a trailing column column comma So that that's one thing you need But once you have something of that stuff set up you basically can start setting up your git server So i'm really just going to run through the instructions here on git's website So i'm going to SSH into my server So here we are now obviously you need to make sure that you have git installed if you don't I already have git installed. I needed it for something else So let's move my face to somewhere where it's a little better So the first thing they're going to want you to do is create a git user Now this I suppose is for debbie a new rubuntu So it's going to ask for a password. Let's give a password to our git user You're not going to be using the password to log in. You're going to be using, you know, your sssh Public keys stuff like that full name whoever put stuff in for this garbage is debbie and bloat So now we've added a user and we're going to I'm going to say su git to become the the user and we're going to say cd to go to his home directory Now the first thing we want to do is actually again, we don't want to have to log in using a password That's not really secure when you could use ssh keys So we are going to create an ssh directory And they they actually want you to chermod everything so we'll do that just so only us can look at it and create a file called ssh authorize authorize Keys if you don't know anything about servers This is or ssh This file is where you basically keep the public keys of all the people you want to be you know, you want to allow to ssh and you know go into the server without a password Okay, basically we want to be able to commit here without a password So that's what we're doing So now we've created this file and they say to change its permission So I'll be a good boy and do that as well Just to be nice and safe So the thing you want to do on your home machine if you have you know an ssh key If you don't have one you can easily generate them But you are going to look at the output of ssh and you should have a file called Rd id rsa.pub So this is your public key. Okay, so I'm actually gonna you know copy all this. Let's not that I don't care about that So let's copy the output of this file And I'll just highlight it. I'll do it the lazy way even though I literally have bindings for all that stuff So I'm going to copy that and I'm going to go here and I'm going to open up The authorized key file blah blah blah and put that in. Okay, so that should allow Let's let's test it out over here. That should allow it Allow us to log in as the get user Without a password. Okay, let's see if that works Okay, so that works So that that is all set up and if you're if you're good if you're using ssh or any of this kind of stuff You should really also disable logging in via password at all You know once you've set up this so that makes your server basically Perfectly secure or more or less as secure it can as it can get Okay, so we've done all this they give you different ways to do all this stuff So now what they do is that you want to have a place where you keep all your git repositories Now they do it in you know server slash git. I don't really like that. I like um Really what I like doing is I like having it in var www Where you have websites and stuff this might be you might say this is stupid, but I don't I don't know It's what I've done because I'm you know, I'm going to make this a clickable website anyway Uh, so I prefer it. I prefer it to be with my other websites. Basically. That's why So I'm going to create this directory. Actually, I shouldn't have created this directory Or no, I should create it as uh create this directory But I want to make sure this is the important thing that the the directory is owned by the git user So we have the git user in the git group and we're just making sure we're running this as root right now We have now created this git folder and it now belongs to the git user Uh, so now what I'm going to do is I'm going to go In here and I'm going to become the git user. So now here we are we are in a uh While we're in this directory Okay, and it should be owned by the git user. Okay, so now basically all you have to do you basically have it set up Um, it's just you have to make individual places for each of your repositories Okay, so let's say I want to start with my dot files. So I will make a directory and again I'm I'm running this as the git user. I'll make it called. Uh, let's see. They make it project dot get I'll say dot files. Okay. Actually, you know, let's not say dot files Let's say dot files dot git because of you know, I think it's officially you're supposed to have Bear repositories with a dot git extension. I think that's how you're supposed to do it That's not what I did last time, but I'll do it this time. I'll be a good boy Um, so once you are once you created that directory go inside of it and just run git init bear That's all you got to do. Um, that's all we have to do on the server side at least Um, so now let's say I'm on my computer here I'm going to go to my dot files repository and I'm going to put that repository I'm going to basically push the changes to this repository we've created Okay, so there's a way of adding a remote repository with like git remote ad or something like that I always forget how to do that stuff. I just added the git config manually. That's probably a terrible habit But you'll see actually here if you open up again, this is a git slash config Um, you'll see that you have like, uh, let's say my origin If you look at this, here's one remote. It's our origin. This is basically github. I have lab. That's git lab And uh, this is from my earlier server where I had my home directory Uh, or not home directory my home server my server were basically the thing we're creating now So you'll see, uh, we're logging in as git at git dot luke smith.xyz and the location is var wwgit slash dot files. Actually now it's got dot files dot git. Okay So now what we should be able to do once that has been added We should be able to say git push home master Remember home is the name of this remote and the master is the branch we're pushing. So I'm going to run that It's it's going to be writing for a little bit. It's going to be doing some stuff Actually, my internet is extremely slow. So it might take a little bit of time Um, but as this loads basically it's going to be putting All of our repository in here. Okay, let's see how long this takes. I'm going to have to cut the video Oh, looks like it's on it says a hundred percent even though it still hasn't gone back to command line So once that is done, um Okay, I'm typing but it's not Okay, there we go. You should be able to type in git log See see how non responsive this is and press enter and you should be able to see your git history Okay. Yeah, see it's not done. Hurry up. Okay. We're just going to awkwardly sit here. It's not going to take more than 10 seconds Okay, maybe it will I'm worried Okay. Oh, there we go. All right. So now We should be able to yes. So if we run git log, we now see that on our server We have our git repository and that's how slow my internet is. I'm sorry about that folks That's just how it is out here. Uh, the prices you pay Um, so anyway, that's it. Basically, we now have a git repository. Um, we can uh, let's see if they talk about how to clone it Oops Let me move this thing Okay, so you can clone your git repository basically by doing this get clone get at your git server and then the location Uh, or if you want you can make shortcuts in your file structure in case you don't want to like write all of this Um, but just to, you know, go a little further. Let's go ahead and add yet another repository. So we have my dot files repository I'm going to make one for my uh, for larbs as well. So we'll say larbs.git. Actually, we might as well make a bunch of them You know, let's say my dwm build my st build should be put in git at the end of all of these dwm blocks Uh, mutt wizard all the stuff that you can get From my github or from now this site. Okay, so I'm going to go ahead and make these But we'll just push larbs already. So again what you do to create a repository make sure you're the git user That's the important thing all all this stuff all the creating directories should be done as a git user If you do it as root You're going to have the wrong permissions You're not going to be able to write and stuff as the git user when you log in But anyway, once you create those directories just go inside get in it bear And then on your local side, let's go to my larbs repository. Okay, so now we're in here and again You want to look at your remotes? Let's see config. Okay And Here's what we want to have except for I added the git Sequence to the end of that and I'm going to say git push home because we named it home master Now additionally there is You know one thing is, you know, obviously I push to github. I push to gitlab and I push to my own home server That actually is not too difficult to do really what I have is I have an alias You know, let's say I make some changes or let's say someone has a pull request on github and I merge it So I'll pull it down to my local repository and then I have an alias gua Which basically does this actually let's go here. So git remote We'll show you all your different remote repositories And then I just pipe it into this xr command that pushes everything to it Actually, maybe I should just have it push the master now that I think about it because I pretty much Whenever I sometimes I'll accidentally push other branches. I don't mean to Because I basically only have master branches because you know, I'm I'm still a git nub frankly even though we're installing our own Git server and stuff like that. Um, all right, so That's about it for this. We're gonna validate that this worked in a second Might take a while But in the next video I do on git it's going to be how to set up stage it So you have a nice interface to actually go in and you know, look at your git commits and stuff like that Anyway, that's it. Okay. This is going to take forever. You don't need to see this. It works Spoilers. That's it. See you guys next time