How to Create and Clone a Remote Repository | Git & Source Control #2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back everybody my name is Nick this is swivle thinking and in this series we're learning how to use git and Source control in the last video we did a lot of setup we created a GitHub account we created a git Kraken account and we updated our xcode so that it is connected to our git accounts so now that we're connected we can go ahead and actually start using it in a project so in this video we're going to talk about how to create a repo and how to clone a repo so the first thing we're going to do is actually create a new project and then push it up to GitHub I think that's how most projects start right you starts on your computer you create a project and then eventually you want to save it push it up to the cloud push it up to GitHub the second thing we're going to cover is cloning your repo so you could imagine that you join a project you don't have the project on your computer yet and you want to download it from GitHub down to your computer so the first time when you download that project if you're downloading the repo meaning all of the git files and Version Control that's associated with that project that's called cloning a project so so we're going to first create a project push it up to GitHub then we're going to take a project from GitHub clone it down to our local machine I think it's pretty straightforward so let's jump into xcode and create a [Music] project welcome back everybody in this series we are learning how to use git and Source control and in the last video you should have already created a GitHub account and connected it to xcode we also created a get Kraken account if you have not I will put a link below you can sign up for free through that link and that will be a GUI your new best friend for using git and Source control so in this video I'm assuming that you're already all set up and connected and we're going to start moving forward here the first thing that we need to talk about is how do we actually create a repo and how do we actually clone a repo so we're going to do this twice in this video firstly we're going to start on our local computer with code and we're going to create a project and then we're going to push it up to GitHub so that's going to basically simulate most cases when you're building your own projects you started a next code and then you push it up to GitHub but if somebody else started the project or you joined a team that project's already on GitHub and then you're going to want to pull it from GitHub down to your local computer that's called cloning when you copy it for the first time down to your local computer you're cloning it from the server from GitHub down locally so when we create a new project here it's asking us do we want to create a new one or do we want to clone one so cloning is what we're going to do later we're going to start by creating our own project and pushing it to get first so this is the case where there is no project created already nobody's already started it and I'm starting it for the first time so I'm going create a new project we're going to make it an app and I'm going to call it Swift Full Source control and click next save it where you need to save it and when you're going to save it the one thing that we want to make sure here now is that we have Source control create git repository on my Mac is checked it should be checked by default but if you don't have it checked and you start a project and you don't have it checked there's a button somewhere in the integrate tab that will say create a new git repository but most of the time when you're creating a new project you're going to just check this it's going to be automatically checked create git repository on my Mac and we can see here xcode will place your project under Source control so this basically means we were talking in the last video about what is git git is this versioning system where it's going to track all of my changes this is saying start tracking changes on my computer we're going to track all the changes now let's also understand that when I'm creating my project right now in xcode and I'm tracking changes that is tracking changes locally this is nothing to do with GitHub yet right now I'm just creating a project on my computer and I'm saying that behind the project we want to put some Source control so that we can monitor all the changes and all the files so go ahead and click create and jump into the project if you did it correctly when you go to click the integrate or the source control tab a bunch of these buttons should actually be clickable now you should be able to commit and push and pull and if you don't have these clickable that means that your project is not under Source control I think you could probably create a new repo if you don't have these lit then you need to add Source control to your xcode project locally so now I have Source control working on my local project so when I go to make some changes and I add more padding here we can see this little blue line appear so if you've never seen these blue lines before your project has probably never been under Source control but if youve seeing these blue lines that means it's been under Source control this entire time so this is a good thing we want to see these lines and these lines are just tracking the changes if I hover over this we can see that this is an unstage and we're going to talk about changes and Stage changes in a future video right now we're just talking about creating the repo and cloning so right now I have this repo it's under Source control but that's it it is on my computer and it is not on GitHub if you go to GitHub right now you can click on your repositories and you're not going to find your project and that's because right now our source control is only on our computer so now we want to create another version of this that is also on the internet going back to this image right here right now git is only on my computer and it's not up here at all so I can't push and pull to the GitHub I need to First create the actual repository the repo the Clone on GitHub when we use this term repository I think about it as like a massive folder so a repo is what's going to hold all of the versioning files for this project so when people say cloning the repo they're talking about repo stands for repository is it's basically just the project with all of the files for Source control bundled inside of it that's what the repo is so right now the repo is only on my computer and not on GitHub and we want to copy the local version so that is also on GitHub so there are two copies of this project one on GitHub one locally and it's actually really easy to do that through xcode now so up here I can click integrate and I can click push and you're going to see there is no remote meaning there is no remote version of this repo as I just discussed there is nothing remote yet this is how you know you're not connected to GitHub so we're going to now start working with this new tab that we've probably rarely worked with in xcode if you've been following my channel normally we're in the project Navigator which is this folder here this blue folder but there's actually another tab here that's called The Source control Navigator so I click on this this is think of it the same way we think about all of our files this is the navigator for for our files this is the navigator for our source control so right now we don't have much we just have some uncommitted changes we can see here list of all the changes one file is content view that has an M for modified if I click on it I can see those changes what has change in content view it's just this this padding line here is what's changed we're not going to worry about that again in this video but we can see the source control from our source control Navigator if I click on repositories I can see all of the repos and so when I click on the remote repo I will see there is no remote repo for this repository so even though we have our local repo and we're on our main branch it is just local and it's not on GitHub I'm going to right click the remotes and create a new remote here so this is now going to create the project on GitHub and if you don't have access to this you're probably not connected to GitHub but make sure you have your GitHub account connected here and then you're going to name the repository generally when you're naming repositor you don't want to use special characters so I would just use lowercase uppercase maybe dashes and underscores but don't use exclamation marks and things like that and and then you can add a description here if you want if I look at GitHub I can see here's one of my packages swiftel routing this is swiftel routing is the name of the project and then this is the little description a little about section so when you see previews of projects like this you can see the name so if you add boot cap and then the description so that's what this is asking you your name and then your description and you can change these later you can come in here and you can edit the name you can edit the description so this is not something that's set in stone the last thing it's going to ask you is do you want this to be public or private private means only you can see it and other people that you invite into the project so later we're going to talk about when you have a project you can invite collaborators so if I'm building a project and I don't want the public to see it I just want to use it and maybe I want one other developer to be writing code with me I'm going to make it private and then I'm going to invite all the collaborators that I want to work on this project so only people I invite can see it that's what private means and if we really want to get into it large companies have Enterprise GitHub accounts so this is just a personal GitHub account company will have a Enterprise account or a business account with a bunch of personal accounts underneath it so there are ways where you can share a repo with a Enterprise or a company so if you have a company you don't need to invite every single person every time you can invite an Enterprise or a company but for most people you're basically just deciding do I want everyone else to see it or not and my personal projects so like this playlist I me to make this public if you want a potential recruiter or an interviewer to see your code you're going to want to make that public if you're making a personal project and you don't want to share your source code you want to keep it hidden maybe it's an app that you're putting in the App Store and you don't want people to copy it you want to keep that private lastly remote name just keep it as origin so I'm going to make this public no description I'm click create once I do this I should see the origin under remotes so that tells me that I do have a remote and you should now be able to go to GitHub and click on repositories and you will see your new project your first project on GitHub how exciting swiftel Source control if I click on it I can see here all of the files in my project so it's hard to see when you first created a project but there's actually a lot of documents that went into creating a basic excl project right we have preview assets and preview and assets folder and content View and the app and there's other files that are not listed here so every single file related to this project has now been pushed up and saved in a repository on GitHub and when I look here I can see all of those projects all of those files so in here and click on this I can see all those files here's the content view here is the actual code that has been pushed up here and just to show you guys how to use this this dot dot goes backwards so if I want to go forward and then I want to go backwards and then go forwards that's how this works this is the GitHub online if you use GitHub desktop it looks very similar as as well but basically I now just have all of my documents on GitHub I'm going to quickly open up get Kraken now and I'm going to open up a repo and I'm going to open up and click on the parent folder of the project and then click open and get Kraken should now give us a user interface to see what is happening in our source control and this for me is the biggest thing for Source control is seeing what is actually happening behind the scenes because when I'm looking in my exco project right now right if I go to the source control it's pretty obvious that there are changes cuz I go to this change here but it's hard to see those changes in comparison to the rest of the source control there is no tree diagram of what has happened but if I look at get Kraken really helpful I can see here's the initial commit so this is what's actually been saved and then here is my current project it's a work in progress we see WIP here and this means this is stuff that is being actively these are active changes in my Version Control that are not yet committed into the repo again we have this one change in the content view or we added padding and I can see in get cracken really quickly there's one change that has not been committed if I click on it I can see the change and I can see that is unstaged meaning it is not staged it is not ready to be committed we're going to talk about staging in an upcoming video so I'm not going to get into that now but this is the start of why we really like get Kraken because we can see visibly what has happened here before we continue to move forward though we're going to talk about cloning so firstly this is all connected and it's working but let's unconnect it and break some things uh to talk about cloning so what I'm going to do is actually go into the folder where I saved my entire project here so I have my Swift Full Source control I'm going to highlight all of the documents related to it I'm going to right click and I'm going to move them to the trash all right don't allow I'm going to close out of xcode probably should have closed xcode first and then you'll notice that K Kraken has also disappeared so right now let's pretend like I don't have this project anywhere if I try to open it it is not saved locally I don't have anything saved for that project so most of the time when you join a company you join a team there's already a project on GitHub so I can see the project here on GitHub but I don't have it locally so how do I get the remote repo back into my X code so there's a couple ways to do it the first way we can come to the repo we can literally click open with xcode now I want you guys to just recognize here that if I click download zip that's going to download all the files to my computer but it's not actually opening up this remote repo so you can download Zips for like small projects that you're not really actually going to be working with the source control but if you want the source control you either need to clone or open up with xcode so now I'm going to open up with xcode I'm going to open xcode and I'm going to do it in the exact same spot where I just saved it doesn't really matter if it's the same spot or not but I'm now basically creating a copy of the remote repo on my local computer so you'll notice when you click this button here it says clone it is creating another copy of the repo you're not changing any files here you're not committing updates you are creating a second copy on your local computer of the remote version so right now we have the project on GitHub only and not on my computer and I'm now taking the base repo copying it onto my computer that's called cloning so I'm going to clone it onto the computer so now when I open this up I should be able to see that I'm inside the source control so I have the same project here you'll notice that our second padding is not in the project because we never actually committed it we never actually saved that change and when I click on the source control we should be able to see the repo so I open this up here I'm on the main branch and there is a repo that we're connected to the integrate all this is connected so it was super simple and I honestly I love that GitHub has this button to open with xcode I'm going to actually close it one more time I'm going to again delete this entire project I'm going to come back into here another way to do this https cloning I can copy this URL I can open up xcode I can click clone right here from the recents menu or I can click integrate clone you paste in the URL and click clone it's going to ask you where you want to save it you can save it back to your local spot one final way that I like to do this is actually through git Kraken so in git Kraken we can click clone a repo same thing we're going to clone from github.com and what I really like here is if I'm connected to GitHub already I can actually just search for the remotes that are already connected to my GitHub so I can see here all of my projects I will search for Source control open that one up and close the repo let's open up the repo quick and we can see that we now have our source control uh locally so we can see all the files that have been committed into the project so far and we have our initial commit now I'm going to open up the project that we just cloned again if anything has gone wrong your folder would not look like this so make sure that you have the actual project here and then the xcode project file as well and at a high level we have now set up our remote repo and our local repo and we can already start to see the benefits of this you could imagine a place where you're working on your computer and your computer breaks maybe you pour water on it you spill your coffee on it you don't want all of your project and all of your changes ever to only be saved on your own computer so now if my computer breaks I now know I at least have another version of everything that I've been working on in the remote repo so this is great for sharing code between people but it's also just great for single developers because you now have a backup you have a place on the internet where all your stuff is saved in case something breaks on your computer or something goes wrong you have a version here so at any time throughout this life cycle now I could delete the entire project for my computer and it wouldn't make a difference for me because I know everything that I've been doing has been saved up to the remote repo and I can clone that whenever I want so that is it for this video we learned about how to create a project and then push it to GitHub as well as clone a project from GitHub back down to our local xcode again if you are in the project you should be able to see now the the project Navigator you should be able to see the local branches as well as the remote repo and on your GitHub you should actually have the repo as well in the next couple videos we're going to actually start versioning and actually using the source control now that we have it set up thank you guys for watching as always my name is Nick this is swiftel thinking and I'll see you in the next [Music] video
Info
Channel: Swiftful Thinking
Views: 738
Rating: undefined out of 5
Keywords:
Id: 6RPjDQXSdOM
Channel Id: undefined
Length: 18min 46sec (1126 seconds)
Published: Wed May 01 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.