Git Tutorial For Dummies

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
every resource about git or github if you look up a git tutorial they over complicate it and i've always said this you might not like this if you're super analytical and you want me to talk like a scientist but the best way for you to understand me is if i talk to you like you're an idiot and when i was in college that's exactly what i wanted for my professors teach me like i'm a five-year-old because that's how i think so i'm gonna break down get instead of you going and watching the six part tutorial or paying or whatever it's really very simple if i teach you it in hey i'm gonna teach you like you are a child and you are my children and if you're my new child meaning you're just born then hit subscribe and like the video alright so this is unscripted but first thing i'm going to say get this out there git and github are two different things i'm going to talk about both of them in this video but i'm going to start with git so let's begin what is git well git is a software that comes with your computer and installed on your computer if you have mac or linux so if you have a macbook or an apple computer you have git already or linux computer you have you already have git if you have windows you have to download it so you're gonna have to download something called git bash you go to the website you download it and then it's like a little terminal window use that is git something you need to know yes git is something you need to know you are not going to be successful at programming without knowing git everyone needs to know it it's like one of the most basic things it's like terminal you need to know term you need to know a command line you need to know git and then you need to know how to code okay so what is git do why do i need to know it here we go this is as simple as it gets simple as it gets get is a memory card for code if you have a project with a bunch of files html css javascript whatever programming language you want you want just like how you have a video game you want to save your progress as you go that way if you die you don't lose all of your progress so with git every so often you're going to enter a command to save your progress now this is locally on your computer nobody else can access this you have this on your computer so i'm going to go through an example now i'm going to create a folder get video i'm going to go into my git video and then i'm going to make an index.html file and an app.css file so i made a folder and i made an html file and a css file now if one of these files gets deleted i didn't save my progress it's gone forever i don't know what was in the file if i wrote a bunch of html or css one of the files gets deleted poof oh well i can't do anything about that it's gone forever but if i use get and i save that i made these files i could save them with the contents of the files and when one gets deleted i can go back to my saved progress now to use git you have to know a few commands there's only a few and it's not that hard to understand the first one is initializing your folder or project with git to do that you have to have get downloaded and then you type get init initialized empty git repository great so that's the same thing as you're putting a memory card into your game system because you obviously can't save the game without memory so here we go now we can use git we want to save our progress how do we do that well git add is what you want to save we can save all of our progress meaning all of our changes since the last time we saved or we could just save a very specific thing so after git add you want to put either maybe a file that you want to save so i could just save index.html but if app.css gets deleted it's gone forever but i could just save any changes i've made to index.html or i can save everything so git add space period would save everything that i've done since the last time i saved i almost never commit a specific file i usually push changes on everything so in 95 cases you are going to use git add period and commit all of the changes that you've made okay so now i've said what changes i'm saving which i chose to save everything now if we were to get technical i have added all files to the staging area but that might just confuse you so don't even think about that i've added the files i want to commit i've added everything i am going to save everything now git commit actually commits those changes to memory so you type git commit and then you need to do dash m for a message dash m and describe the changes describe the save this way when we look back if we want to go back to this save progress we know what we're going back to so you make the message about what you're saving makes sense so i'm going to say add html and css file two files changed you see that i created two files it got saved that progress got saved now if i delete my html file and i add a javascript file well now i've made some more changes and i could save my game again so now we only have app.js and app.css so let's do it again save all my changes git commit dash m delete html and add js so i've saved my progress twice now what we've gone over so far is how to add the files you want to save and then commit with the message to you know save the progress of the message and get in it to you know start it up now if we type git log we can look at our saved the times we saved look at this so this is the first time we saved it it's a log get log it's a log of all of your saved changes add html and css just gives you the time gives you the date fantastic and then it gives you this little hash code used to go back to it and then look at this there's our second one time and date with the hash code now if i want to go back to my previous progress with the html and the css where we saved i can copy this like hash code thingy majig and then look at this get checkout to check out that commit let's see where we're at oh we're back to our first saved progress now here's the tricky part is that when we go back in time we're in a different branch so so now timelines are getting messed up and we're in a time machine oh god dude maybe maybe i shouldn't go with the time machine analogy i want to keep this i want to keep this organized and i don't want to give too much to you to confuse you now what is github now what is git hub well github is a website and it's the same thing as bitbucket and it's the same thing as git lab they are websites where i just put the stuff that's on my computer all my saved progress is on my computer and i put it all on the internet so that other people can download my code and then go through all my saved progress they could go back and forth they could jump through time loops and go back to my save progress and look through all my code and do whatever the hell they want to do so how do you get your code onto github well you make a github profile and then you make a repository repository means folder folder means repository same thing so you're on your thing you go to repositories on your profile you hit new you hit new repository you type the name of it mine was get video description you could have a public or private whatever so now once you do that it gives you instructions to hook this up to your folder on your computer my folder is on my computer i want it on the website it tells me how to do that it gives you specific instructions it says get remote add origin this is a command to just hook it up to the website so let's just do that alright ready boom okay i added the origin and now this is called a push so you have your saved commits you save progress and then you push it you push to the website okay and now we go to the website and there is our code people ladies and gentlemen there is our code the css the js and then the two commits that we can look through here's the first one with the html css here's the second one now someone else can go to my profile and see this and they can download it onto theirs and that's why github is something you have to know so you can work with others on projects from different areas in the world because whenever i save my progress i push it up to github and whenever they want to see what i'm doing they go to my github and they can just pull my code down or they can just look at it on my profile now do i want to go into branches right now no i don't this video's already been long enough but i will now there's these things called branches so the by default all the code is on a master branch don't overthink this i know you're overthinking that that just means that's regular that's just regular that's just you coding you're saving your changes they get saved to the master memory but someone can go off like in a video game they could trail off your game and then you know when you play a video game and then you do something and it's on your friend's account but you don't want to save onto their account because they still might want to play what you just did so you save it into a new file so that's a different branch someone could download my code make changes and they do it on a different branch so if we go back to our folder and i type git checkout dash b that's going to make a new branch and i'm going to call it new branch you put the name of the branch you want to make so now i have a new branch open and there's a master one still but now i have new branch and i can make changes and it won't affect the main game saving the main code getting saved it will just be my own branch trailing off of that code so i'm going to add a python file app.pi and i'm going to commit i'm going to do git add everything add all my changes git commit add python file and now if i do a git log you can see i got my three commits and this but this is for my new branch i'm on new branch here but this stuff is from master now the cool part about branches is that i can merge my changes on new branch into master if i want to or i cannot do that if i don't want to so if i want to merge all of if i change like 50 things on my new branch i can push them all into the main one if i feel like it and if i don't want to then fine i don't i could delete the branch i could do whatever i want it's irrelevant until it goes into master so the point of branches is so that other people can download your project they can go and make changes on a separate branch and then they could come to you and be like dude i made all these changes i didn't want to mess up what you were doing but hey look at these if you like them merge them into what you are doing and then i can so what they would do on github is they would say hey let's push origin new branch you could push the new branch up to github oh look at that there's two branches on github now one of them is new branch one of them is master so if someone wanted to say hey dude check out my progress they could do what's called a poll request and whoever owns the repository is gonna get that and look it over and say hey these are good or not so you could say hey dude i changed some stuff check it out and then you create it and then whoever owns the project might be like oh this guy wanted to change some stuff let's see what he changed oh they looked he added a python file maybe i want that so that looks pretty good good job dude you made some good changes and then you merge it into the master and then you confirm the merge and look at that dude now it's merged into the master and you know dude it's got the the commits from the new branch they got pulled into the freaking master branch so now everything is in the main area because the guy liked the new branch now one thing that's important is you always want your local computer synced up to github you want these connected because it could get out of whack you need these to be at the same spot so when there's changes on github that you don't have on your computer you want to pull those changes down to your computer you push when you have changes that github doesn't have you push them up to github when github has changes that you don't have you pull them down from github so i will do git pull origin master and now i pulled down those changes that python merging that went on up there i got them now on my computer and we could check that out we got the merge we got the python file and everything is now on our local computer now for rebasing i do need to get a little more technical with this and i think i might make a future video specifically about get rebase but these are the basics and you can probably get by on just these and maybe pick up rebasing on your own i don't want to over complicate or make you overthink these are the basics this is all you need to get started using git and github you don't even need to get into branches really because you might not even be working with those right now just pushing your code up pulling your code down making the changes the save changes when there's stuff on the github that you don't have pull it when there's stuff on your computer github doesn't have push it you do not need github to use git and you you probably do need to get to use github but you don't need a github if you just want to save your changes but you need a github probably when you want to collaborate with other people in different places and you'll probably need it for like every project ever now some parting words about github that you might be interested in people will judge me because i don't have all these green squares so if you want to set up some kind of auto commit thing you get a green square if you push code to github every day so people like to code every day and have all these squares look green and sometimes they don't push anything useful they might specifically change or add a comment just so that they have a green square on github these are people called clout chasers specifically github clout chasers and uh they don't make impactful contributions to projects and they specifically want green squares to flex on other developers you can be one of them or you can let it go and just move through and actually you know do real things with your life so that is it for this video i hope i made this very easy for you to understand and i'm going to put a black screen at the end with all the commands we went over and there's only a few and it's pretty straightforward so that is why this video is the best get tutorial out there please like and subscribe to show me support thanks for watching and i'll see you in the next video video bye you
Info
Channel: Nick White
Views: 467,691
Rating: undefined out of 5
Keywords: coding, programming, software engineering, nick white, git, git tutorial, github, git for dummies, git made easy
Id: mJ-qvsxPHpY
Channel Id: undefined
Length: 19min 25sec (1165 seconds)
Published: Sun Apr 04 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.