What Is GitHub and How To Use It?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there so as you're learning how to code you'll eventually run into this tool called GitHub and you'll be wondering what is GitHub and should I be using it every software developer I know uses git and git is such a huffle tool not only for your individual projects but it's also helpful in terms of how you work with teams and you code together with with teams and it allows people to work together on the same code in parallel and it's especially important in production code because in production code sometimes there's a break in your code and you're trying to figure out what what caused my code to break and having that's when having git is really helpful because you can go back to different older versions of your code and see uh where did the where did this feature stop working where did that feature stop working and it's really helpful and there's a lot of things that can happen when you're coding with other people and git just makes things much more simpler and easier to follow so in this video I'll be talking about git and GitHub and GitHub what GitHub is is it is a way for someone like you and me to use git it's one of the most popular ways that you can use git in your personal computer so I'm going to be talking about GitHub and git and I'll show you how you can get started and what are some essential commands just to get started I'm going to talk about more advanced tricks later on in other videos but this purp the purpose of this video is just to get you help you get started my name is Henrik and I'm here to teach you how to program your own applications stress less build more save time and improve lives and the lives of others all right so before we begin I would like to mention that I have a free guide called my personalized finance app programming guide it will teach you how to build your first app starting with note from no coding experience to building your first app and in this application it takes your credit card transactions this is like a file that you would get from your credit card company and then you can but you can categorize your transactions into different budget categories so you know how much you're spending in those different budget categories it's a free guide again it's a 12-step guide and if you download it pay attention to what it says you'll definitely learn some fundamental programming Concepts and you can download it in the link in the description all right like I said before the purpose of this video is just to help you get started there's a lot of advanced things you can do in git but what I'll teach you today will help you just to get into the rhythm of using git and also start to see some some of the benefits of using this tool so what is GitHub GitHub is an online service or platform that allows you to use git in your software development but what is git git is a version control system that tracks changes to your code so I think there are two main uses for git one is for your individual development and one is for working in teams two main uses then the first one if you've ever programmed before you'll realize that there are times when you want to save a backup of your code like say you finally get a feature to work or you finally get something to work you want to save it make sure you never lose that code again because if you're continuing to develop your code sometimes you break your own code with new developments with new features you start out you start to break your code but you want to save a version of your code where that feature was working and so what I did before when I started programming was I would code until I had a certain feature and then I would save that file call and then name it like main1.c or mainbackup.c and then I'll continue coding in my main.c and eventually you can reach a bunch of milestones in your code you reach oh I'm able to program this I'm able to program that feature this feature that feature and what what I did was I was saving like main main one dot C and then main two dot C and main three dot C so if you've ever had to do that with your own code this is where something like git would be really useful you can think of it like constant backups if you've ever used time machine for Mac then you kind of understand this concept if you ever mess something in your Mac or you lose a file you can always revert back to an Old State you can revert back to a version of your Mac when you had that file or when this file was a certain had this type of data in it so the Second Use case forget is when you're working in a team sometimes you'll be coding on one part of the program and then someone will code on another part of the program but you both can't just code on the same machine you want to code under your own computers in your own development environments and git allows you to do that because you can start coding your code in your own version and then someone can be coding in their own version and then when say one of you finishes first you can push your version to the main version and then you can tell the other you can you can take their version into your version and if all that sounded confusing I'll go through an example later in the video but basically you can think of it kind of like Google Docs right if someone is on Google Docs someone has a Google doc open and then they're typing away and then you have a Google doc open you're both editing like the same document but what Google Docs does is it allows you both to have your own changes be made into the same file and so git kind of allows that possibility to happen so you can both work on the same project at the same time and this will become more clear when we go through our example so today I'm going to show four main commands in git that you'll that you need to use first one is git clone the second one is git add the third one is git commit and the fourth one is git push and basically you can think of them like this get pull get clone is kind of like opening a file so if you want to start working on a pro a program you have to use git clone to get the program okay and the second one git add is basically you're telling git that I'm making a change to this file so if you make a change to one file then you have to add it and we'll get we'll we'll go through an example so you understand what I'm talking about but you're basically declaring that you're going to make a change to this file git commit is like you're saving a file on your computer you want to save the changes and you commit the change that's what what commit that's what commit means and the last one is get push and basically what this means is you're saving your your change remotely you want it to be saved into some server somewhere so that other people can get that change in their versions as well all right so let's go through an example first you need to set up GitHub so all you need to do is you go to type in GitHub and then you go to github.com and then you're brought here and then you sign up then you enter your email I already did this so I'm just going to sign in all right so this is the GitHub that I have for this tutorial and basically you have to create a repository if you're going to create a new project you have to create a repository and as the name suggests basically it's just a place for your code so we create a repository let's call it tutorial okay so we created a repository but before we can clone it we need to create some keys for SSH and we could talk about that in another video but just to get you started all you have to do is open your terminal and type SSH Dash Keygen and then you just press enter keep pressing enter and you have to you have to copy this key so I'm gonna copy the key so we're going to take this this key copy it and then we go to our settings scroll down to ssh in Keys new SSH key and it'll say call it my key or default then you paste your key there and add SSH key so now you have the key here let's go back to our Repository all right there's the URL now we do a git clone all right there you go there's our repository but it's empty right now there's nothing inside so say you're the first user you want to create a file so let's create a file main.c okay then we do an add git add then we do a commit and then you create you add the message git commit Dash M and then the message that is associated with the change that you just made and you just say I just added a line of code oh yeah I forgot we need to configure our git first so do just copy just copy the recommendations here git config okay let's try it again okay we've committed it locally now we want to push it to our repository that's from our remote Repository okay git push now you have a new branch called main a lot of people they have a branch called master and that's like the master branch and basically what branches are in git is like different uh streams of versions so we have once one main Master branch that has the main all of our code will eventually be in master and then whenever you start to make changes to master you create your own Branch like I'll create my own branch called Hendrix branch and then I'll make all my changes there and then I'll bring the change into Master but we'll talk about that in another video but for now just we'll just stick to one branch for now just to make things simple so there's Main now we can check online because we pushed it to remote so we can check our GitHub and see the actual branch all right there it is so this is the branch here Main and we only have one branch that's the main branch and there's my there's my name so you can see who made the change and then you can see my message I had I just added a line of code now you don't create these kinds of commit messages but just to get started just an example uh there you go so now we can click this we can click it and it tells us what the change was so basically I just added these three lines okay so just to prove the usefulness of this let's pretend that I go to a different computer and then I I don't have this directory tutorial pretend I I don't have this directory it's not there it doesn't exist here you can see it doesn't exist anymore I deleted it but say I wanted to start working on that code again so all I have to do is do the same thing that I did before just do a git clone let me go back to using that link that I had earlier okay so you can go here and you'll see the SSH link and then press enter and then you can see the tutorial directory that we created the tutorial repo and then there's our file that we had earlier we can look inside the file and there's the file it's right here all right now let's go into let's go into the example where you have two people working on the same code so let's pretend there's two people there's a there's Bella and then there's Alvin Say Alvin was working here and let's just pretend that I'm Alvin for a second so I'm gonna go into Alvin's directory in terminal so here I'm in Alvin's folder so what I would do is I would do the git clone and then use that same link again and there's a repository and then I'm going to make a change to main.c all right so I need to add the file saying that I made the change and then I'm going to commit and I'm going to use just to save it locally I'm going to make a I'm going to make a commit and I'm gonna say Alvin made or Alvin added the main function and then I'm going to push because I push to Main if you have multiple branches you can do git push origin Main but we could talk about that in another video and if you go to the local or you go to the remote repository you refresh there you see Alvin added the main function and now we can see Alvin's changes here so he added the main function okay so now let's pretend Bella is working right so let's go to Bella's folder and let's pretend for a second that I'm Bella so here I am in Bella's folder I'm going to do the same use that same command that we use to get to clone so now I have the folder there I'm gonna go into the folder and then I'm going to edit main.c and there's Alvin's change so now as Bella I'm going to add the rest of the function I'm going to put a message saying hello Alvin okay so I made the changes Bella then I'm going to add that change saying that I made this change then I'm going to commit the change Bella completed the main function and then we're going to push so now if we refresh this there you go we see Bella completed the main function now if you go to Alvin's directory or Alvin's folder you go back to Alvin's folder and you go into tutorial if you look inside main.c Bella's change is not there that's because Bella made a change and she made it she pushed it to the remote Repository but Alvin just has a local version and it's not up to date he needs to re-download the the remote version so what he can do is he can hear he can get an email from Bella or message from Bella saying that she made a change and all you have to do is Alvin if you're Alvin you just do get pull and then you can see that someone made a change to main.c now we can look inside main.c and see what the change was and it says hello Alvin so that's the change that Bella made earlier and now uh as Alvin we can compile it and then we can run it and there you go so now Alvin and Bella have just worked together on this project even though very simple but there you can start to see some of the benefits of using git all right so that's today's video forget I hope it was clear if it was confusing feel free to leave a comment and I'll get to it and hopefully I can make things more clear for you and this is really important git is a really important tool for if you're going to be a programmer if you're going to be a developer it's kind of like addition and subtraction if you're going to learn calculus you have to know addition and subtraction likewise if you're going to learn how to code you're going to have to use git and it's it's kind of hard to get used to in the beginning but when you start using it you'll realize that you can't code without it and when you start working for jobs if you don't if you tell them you don't know how to use git they'll be they'll be confused or they'll think you're they'll start to wonder like how are you coding if you don't know how to use git so git is really helpful and it's not even just useful for C it's useful for python Java C plus plus any type of coding people are doing it through git so git is really useful to know and if you're learning how to program for the first time I do have my guide my programming guide called my personalized finance app programming guide and basically it will help you go from no coding experience to building your first app and I think it's really helpful because when I was learning in University what really helped me really get to understand some programming Concepts is by building my own application and this is one one application you can use git with and if if you start to code your application you have some practice you can start practicing your you can start practicing using git with this application so download it in the link in the description and again if you have any questions feel free to ask me all right thank you for your time and I'll see you in the next one
Info
Channel: HenrikM Dev
Views: 1,527
Rating: undefined out of 5
Keywords:
Id: sAnH-25aA7U
Channel Id: undefined
Length: 19min 13sec (1153 seconds)
Published: Thu Feb 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.