Git & GitHub Crash Course For Beginners
Key Takeaways
This video tutorial covers the basics of Git and GitHub, including initializing a repository, adding and committing files, and pushing changes to a remote repository. It also covers branching and merging, as well as using Git commands such as git add, git commit, and git push.
Full Transcript
hey guys in this crash course we're going to take a look at git Now by no means is this a complete in-depth course where we're going to go over every command in every situation uh this is meant to be a non-nonsense guide for beginners um so either new or intermediate programmers or developers that either don't know what git is or have used it briefly but still don't really grasp the full concept all right so we're going to start out with a couple slides and then we'll jump in and we'll look at some of the most important commands for you to know all right so let's talk about what git is it's a version control system for tracking changes in computer files all right so it was uh initially created in 2005 by lonus Torvalds who was also the creator of Linux um there's no specific language or framework or or anything that you need to use git um you can use it for static HTML websites node.js apps uh python Java C anything at all it just stores files so git is a distributed version control system or or decentralized version control system and what that means is that many developers can work on a single Project without having to be on the same network okay so there's also Version Control Systems that developers actually need to be on the same network to use that's not what git is it's distributed or decentralized okay get uh coordinates work between multiple mple developers and it tracks every single version and every single change that's made um on on the system or on the in the project um you can also revert back to specific versions of any file at any time as long as it was committed to the repository um usually when you use git you'll have a repository on your local machine that you work on you make changes uh and then you upload it to or you push it to a remote repository okay so something like GitHub or bitbucket um and then you can push uh you can push your local repository to the remote one um you don't need an internet connection to work on a repository uh locally and you can make changes but if you want to push it to the remote repository you will need an internet connection all right so let's quickly look at some of the concepts of git so it's it essentially keeps track of your code history with snapshots of your files all right so you make these snapshots by making a Comm with a simple command and you can always go back to see any snapshot of of previously written code uh and like I said you can always revert back if you need to so your code is extremely safe when you're working with Git um you can put your code in a staging area before actually doing the commit and writing to the snapshot uh this is done with a simple add command okay uh and I'll go over all the important commands uh once you make a commit to a remote Repository other developers can then pull that information onto their machines okay so you can create um you can also create branches uh but we'll get into that in a little bit all right I'm trying to just really stick to the basics here okay so let's look at the basic commands that you'll need to learn so git and knit will initialize a git repository so you go into a folder via your command line or terminal and you do get a knit and it'll create a dogit folder uh in that in that project okay and it's hidden by default um you almost never need to go into this folder at least I never have all right and then once you initialize that folder as a repository you can then start to run other commands all right so get add will add the file or files that you specify to the staging area or the index and they'll then be ready for commit um you can run this command as many times as you need to before committing and it'll just keep the files in that staging are area so if you want to see what you have in the staging area and ready for commit you can just use get status and that'll display paths uhu that have it'll display the differences between the the working tree and then the staging area or the index all right so uh when you're ready you can go ahead and commit your files so you run get commit and that'll take everything that's in the index or the staging area and put it into the the local Repository there's also some important flags that you need to know or options that you need to know with get commit but I'll get into those a little later all right so uh the next three commands that I'm going to show you have to do with remote repositories so if you're working with GitHub or bit bucket something like that okay so get push will take your local repository that you've created and then push it to um a remote repository such as GitHub um you will have to add for instance GitHub um or another remote service you'll have to add that and you'll have to add your credentials so it'll ask for your password and so on um you can also create SSH keys with GitHub um so that you don't have to add passwords or anything like that so if you want to pull the latest changes from a remote repository you can just do get pull all right so if someone makes a change and you want the latest version um you can use pull use the pull command and then clone will copy a remote repository into your current folder so if you find a program or a project or module that you like on GitHub um you can simply clone it and that'll download it to your machine so installing git is is pretty easy no matter what system you're using if you're using Linux it's a simple package command for Debian use apt get uh for Fedora use yum and if you're on a Mac you can go to uh this URL right here this git SCM and you can download git uh I believe you can also use home brew or or some package manager um or something like that and then for Windows there's a few different programs you can use but I'd always suggest this g- scc.com um you can download the installer and you can set it up really easily so this also comes with a tool called git bash which is a command line tool and it gives you a more Linux environment on Windows um I almost always always use that tool over the standard Windows command line um now there there is graphical tools that you can use where you don't need to use commands but I would strongly recommend that you use the commands uh because if you only use the the the guey the GUI you're not really learning anything uh you're not really learning how git Works under the hood and if if you end up somewhere where you don't have that tool you're going to be lost um and it's not like it's really hard if it was if it was really difficult then maybe I'd say I use that but it's not hard at all all right at least for the basics it it can get complicated to really really know um how it works internally but uh for things that you're going to need it for uh most likely you're not going to need to know everything okay and it's pretty simple all right so that's going to be it for the slides let's go ahead and jump in and I will show you how git works all right so we're going to go ahead and get started and install git now I'm in Windows um if you're on Windows or Mac you want to go to get- scc.com and if you're on a Mac you can click on this link right down here and that'll take you to the download page for a Mac for OSX uh but we're going to go ahead and click download on Windows and that's going to start the download and again if you're on Linux you can use your aptg or your yum package manager whatever it is you use okay so let's go ahead and open this up and click yes so it's just a wind standard Windows installer we're just going to click through program files is where it'll be stored I'm going to choose the default for those now this option here I always choose the last one which is use get and optional Unix tools from the Windows command prompt so it just gives us some extra commands to use so I always choose that option and then the rest of these uh line ending conversion I'll just leave the default uh terminal emulator we'll just use that default and we'll keep enable file system caching credential manager uh that's fine and that's that's good okay and we don't want to use this experimental tool so click install and it'll install it on your system okay so once that's done we're going to uncheck uh release notes and let's do launch git bash Okay click finish and then this is the git bash tool that uh they give you so I would definitely suggest using this over the standard Windows command line so now if we say get-- version you'll see the version you have yours might may be different um and then you can also use this from within the standard command line so if we go CMD and we open up the Windows command line and say get-- version it should also work okay so you can use get from either one now what I'm going to do is create a project so let's see I'm on my desktop I'm going to create a new folder and I'm just going to call this my app what we put in here doesn't really matter um so when you have get bash you can also go ahead and uh rightclick and do get bash here and that'll open up a window there as well all right so I'll just use this one and you can hold control and scroll and you can make this bigger or smaller which is nice okay so what we want to do first let's open this up as well kind of have both of these open at the same time okay so what I want to do is just create a couple files that that our project would have so let's say touch index.html yeah or you could use your file manager and let's create create an app.js okay so we have these two files that this is our application and what we want to do is let's open up I'm going to open up atom which is the text editor that I'm using okay we'll move this over here and I'm just going to add that folder as a project so desktop my app and let's close this stuff up and let's just open up index HTML and we'll just put you know standard HTML tags in here put a title and body we'll just say this is my app okay we'll save that and now what I want to do is I want to initialize this folder as a git repository so to do that we just want to say get and knit okay for initialize now once we do that it's going to create a doget folder in your f f in your directory now we can't see it here because I'm on a a new Windows installation and I don't have hidden files enabled so what you want to do if you're not seeing it here is go to view uh options and then change folder search options go to view and then show hidden files I'm also going to uncheck hide extensions for known file types because I want the extension to be shown all the time so let's say apply okay and now you'll see there's a dogit folder now this stuff in here don't worry about that at all uh that's just the the git files I don't even know what half the stuff means so we're not going to look into that there's no reason to um so now we have this initialized as a git repository so we can start to use git commands now one thing you should do before you uh before you start anything is you want to add your name and email address to git so to do that use the config command so get config D- Global and then we're going to do user.name user.name and then in quotes just put your name okay and then we're going to do the same thing for the email so we'll just change name right here to email and then just put in your email okay so now that that's set up let's go ahead and let's create uh or let's add the index HTML file to our git repository so to do that we can say get add and then index.html all right so it doesn't tell us anything when we do that but if we want to check to see what's in the staging area we can do get status okay that's a command we're going to use quite a bit and what this is telling us is that the index file has changes to be committed and that we've added it to the staging area and then appjs is a file that's untracked okay so it's telling us to add it um so if you want to remove for instance index HTML from the staging area you can do get RM so let's go ahead and do that so if we say get RM and we want to add the dash dash cached option and then index.html okay and now if we do get status you'll see that both files are now untracked now there's different ways you can add files for instance we could say get ad and we could use a star or asterisk and say HTML and what that'll do is it'll add any any HTML files to the staging area so now if we say get status you'll see that it added the index file it also would have added any other HTML files that we had all right so I'm going to go ahead and take the index out again with the RM command and then I'm going to show you how to add everything okay so if you want to add every file you can say G get add Dot and now if we say get status you'll see that both the index and the app file are in the staging area okay so we haven't committed them yet what I want to do is edit one of these files so we'll go over to index HTML and I'm just going to put in a exclamation here and then save and then if we go and we say get status you can see we now have this um changes is not stage for commit index HTML so this means that we have Chang we've added some kind of change in the file while it was in the staging area so it's telling us to go ahead and add it so we'll say get add all again and then get status and now you can see that it's back in the staging area all right so now we're going to do a commit so for that we say get commit now there's uh an option that I would always suggest you use but I'm going to show you without it first so if we say get commit it's going to go ahead and open up this Vim editor which can be a little confusing because if you start to type it's not going to do anything what you need to do is Click I to go into insert mode and now I can type okay so I'm just going to say initial commit actually I'll just go uncomment it down here these um number signs are basically comments okay so anything that has a number sign in front of it is treated as a comment so I'll just just going to remove it from this initial commit and that gives us a comment of initial commit okay now to get out of this we want to do a Escape which takes us out of insert mode and then we want to type in Colon WQ and enter and now you'll see that those files have been committed and it tells us how many files have changed and it gives us the file names okay so that's how you do a commit so if we were now to say get status it says nothing to commit because we've we've already committed all of our changes if we were to go edit a file now and do get status it'll show us again which files are in staging and which files are unchanged all right so let's go ahead and edit the appjs file I'm just going to do console.log and we'll just say hello save it so now if we do wow this is slow slow machine get status so that's been modified appjs now I'm going to go ahead and add it with get add all all right now I want to do a commit but I want to show you how we can skip that whole edit stage so we can say get commit and then add- M and then do a our comment here so we'll say changed uh changed appjs and enter okay so now it's made that commit and it's skipped that whole editing stage we just included the comment within that command Okay using- M all right so now what I want to do let me clear this out I want to show you how to use get ignore so this is a file that we can include uh the files or folders that we don't want to include in our repository at all so even if we do get add dot where it adds everything it's not going to add that so let's create it we'll say touch. get ignore now if you try to create this file in Windows in the file manager you probably won't be able to because it starts with a DOT so it's going to look at it as an empty name um so either do our touch touch command or you can create it inside of an editor I believe um all right so what we want to do is open up get ignore and we're also going to create a file that we wouldn't want to include so so let's say oh Jesus let's say touch and we'll create a log. text usually you don't want to include log files so let's add something to this we'll just say um error logs and we'll save that and let's go into get ignore and we'll say log. text and save that's all you have to do is add the file name now if if we go over here and we say get add all and then get status you can see the only file that's in the staging area that's changed is get ignore normally log. text would be there because we just changed it but since we added it to get ignore it's not going to get added okay um you can also add entire directories so let's say we have we'll say dur one oh man this is slow and let's do D two and inside these I'm just going to create let's say new file and app [Music] 1js and let's see in inside dir 2 we'll create a file called app 2. JS and we'll just add something to those okay we'll just put that I'll copy it and we'll also put that in app one okay so if we go to get ignore and let's say that we don't want dir 2 included at all so we could just put in slash dir 2 wh okay and save that and let's go over here and we'll go get add all and then get status and notice that only D dur one is in there even though dur 2 has a file that we changed it's not in there because we added the whole folder to get ignore all right you could even add you could say star. text and it'll it'll uh with draw all text files okay and there's there's other Expressions you can do as well I'm not going to go through all of them um it's all in the do documentation but just know that uh if you don't want something included you want to use get ignore or do get ignore all right so let's close these out and the last thing I want to look at before we we look into remote repositories is branches all right so let's say that you're a developer working on a project with a bunch of people and you're assigned the task of adding a login okay so you don't want to start making changes and you know push to the repository and have the main code based codebase edit edited and changed without finishing the pro or the the functionality okay um so what you would do is you could create a branch called login or whatever um and then work in that branch and you can still commit it and and all that but it's not not going to be committed to the main branch okay which is called Master you can see right here when we say get status it tells us we're on the master Branch Now to create a branch we can say get branch and let's just call this uh my Branch all right actually we'll just call it login all right we'll pretend we're adding some login functionality all right now just doing that doesn't change us to the BR Branch if I say get status it still tells us that um oh I didn't commit these changes so let me just commit these before we go ahead and switch branches so we'll say get commit dasm and I'll just say another change okay so um you'll see that got committed to master because we're not in that BR the login Branch so to switch we can say check out and then the name of the branch okay so now we're in the login Branch so I'm going to clear that out and then I'm going to say get or not get let's go ahead and create a new file while we're in this branch called login. HTML okay so over here let's go into login and we'll just say whatever doesn't matter login and save and let's also edit index HTML so I'm just just going to add down here I'm just going to say login form and save okay and then let's say get add all and then let's commit it commit DM and we'll say login form okay so now let's go ahead and switch back now when I do the switch watch the login HTML so get checkout master and now the login HTML file is gone and if we look at index HTML that part of it that we edited is also gone so the reason for that is because that that's in the login Branch now if we want to merge that if we finish the functionality and we're ready to merge then uh we can say while we're in the master get merge get merge login all right so um it's going to open this editor up so let's do I and let's see please enter a commit message to explain why this merge is necessary so we'll say added login and then we'll do Escape colon WQ enter okay so now even though we're in the master branch we can now see the uh login HTML okay now there's a lot more to branching and merging if you want to get more complicated but this I want to keep this simple for beginners there's a good chance if you're working on your own projects that you won't even use branches all right so let's go ahead and now work with a remote repository so I'm going to go to GitHub all right so I'm going to go ahead and just sign in if you don't have an account just create one it's obviously free uh okay so uh what we want to do is go up to create new new repository and I'm just going to call this my app sample you can call it whatever you'd like put a description just say sample app for tutorial okay so you have the option of public or private so public anyone can see it um you can choose who can commit private you can choose who sees it and commits and I believe private costs money I'm not sure I've never actually tried to create a private repository um on my account and you can also choose to initialize it with a readme file if you want I'm just going to leave that unchecked um you can also choose to add a get ignore which we already have or a license so let's go ahead and cck click create repository all right and then it'll take you to that page which has nothing in it so it's just giving us this message here and it tells you exactly what to do okay so um you want to initialize your directory which we've already done it's telling us to add a read me but you don't have to um but you probably should especially if it's a public repository because you want to add some information on your application and you want to use MD to for it to be able to display nicely uh on uh on the page okay and MD is marked down um now it's telling us how to make a commit but we don't actually have to do this stuff what we want to do is add this repository as a remote repository if we go over now we say get remote that'll list the remote repositories which we have none so let's go and copy this and we'll paste that in here run it and then let's say get remote and it'll say origin so down here what we want to do is get push and then - origin master so let's go ahead and do that I'll just copy this okay we'll paste that in and that should push it to that repository oh yeah okay so we do have to log into GitHub it has to to uh validate your credentials let's see try.com [Music] and password okay so now it's going it's going to push to the repository to the master branch and let's reload this and now you'll see we have our files here all right and then down here it says help people interested in this repository understand uh your project by creating a readme so let's go ahead and do that we'll say touch readme.md all right and we can open that up oops I clicked the wrong editor it's going to open up vs code okay so let's open up the readme and I'm not going to go through the syntax of markdown um it's pretty easy if you want to just look at the documentation but we're going to put a Heading by using a number sign here and we'll just say my app this is my app and we'll save it let's go ahead and add it and then we'll commit say commit and we want to add DM comment we'll say added read me okay so right now it's on our local repository we haven't actually pushed it yet if I reload you'll see it's not there so now that we've added that as a remote repository all we have to do is say get push and it'll push it right to GitHub okay so now if I reload you'll see we have the readme file and it's actually displayed here now if someone wanted to get this they could just clone it okay if we go to clone or download right here they could choose to download it as a zip or they could clone it using this so I'm going to go ahead and copy that link and then let's uh let's create another folder and we'll just call it my app 2 and let's open up uh git bash here and then what we want to do is say get clone and we'll just paste that link in and it's going to pull everything in now I actually okay so what it does is it actually creates the the folder for you um my app sample so it pulls the entire folder in but if we open that up you can see we have the entire application here okay and you can clone anybody's anybody's um project as long as it's public now if you had multiple developers working on it and someone else made a change um and we want to go over here back to our original folder you could just do get pull and that would pull everything down and you can see everything's up to date okay uh I think that's as far as I want to go into this we covered all the basics all the basic commands you need to start using git um I would suggest if you're not using it uh at least now start to create your repositories for your project um create a GitHub account if you don't have one uh create the repositories on GitHub and then push from your local machine to to the GitHub repository all right and you don't even have to use branches and stuff you know you're just starting out just getting used to it all you really need to do is adding commits and push okay so hopefully this this helped some of you guys um I'm sure some of you um already know all this stuff and hopefully you just used it as a refresher or whatever all right so that's it if you enjoyed it please subscribe leave a like leave a comment and I'll see you next time
Original Description
2025 Updated Version - https://www.youtube.com/watch?v=vA5TTz6BXhY
In this Git tutorial we will talk about what exactly Git is and we will look at and work with all of the basic and most important commands such as add, commit, status, push and more. This tutorial is very beginner friendly.
DONATIONS:
We spend huge amounts of time making these videos available for free. Any donation is greatly appreciated
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KLVYJVNUJ5NV4
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Traversy Media · Traversy Media · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Changing Your DNS/Nameservers
Traversy Media
Create a MySQL database in cPanel
Traversy Media
Install & Uninstall Joomla Extensions
Traversy Media
Adding and linking an article in Joomla
Traversy Media
Create a Joomla Blog
Traversy Media
Import & Export A MySQL Database
Traversy Media
Use A Custom Font On Your Website Using CSS
Traversy Media
Connect Joomla Site With Dreamweaver
Traversy Media
Remove Phoca Gallery 3.2.3 Footer Text
Traversy Media
Drupal 7 Security Update 7.19 to 7.20
Traversy Media
Add An Addon Domain In Cpanel
Traversy Media
Pull A Heroku Rails App and Database
Traversy Media
Create a Custom Joomla 2.5 Module - Part 1
Traversy Media
Create a Custom Joomla 2.5 Module - Part 2
Traversy Media
Create a Custom Joomla 2.5 Module - Part 3
Traversy Media
Joomla SEO Tutorial - sh404sef Configuration
Traversy Media
Font Dragr
Traversy Media
Convert an HTML Template to Joomla 2.5/3.0 - Part One
Traversy Media
Convert an HTML Template to Joomla 2.5/3.0 - Part Two
Traversy Media
Rockettheme Rocketlauncher Joomla Site in Under 10 Minutes
Traversy Media
JQuery FAQ Slider Tutorial
Traversy Media
301 Redirect With htaccess File
Traversy Media
Convert HTML to Wordpress Theme - Part 1
Traversy Media
Convert HTML to Wordpress Theme - Part 2
Traversy Media
Easy JQuery Widgets
Traversy Media
Codeigniter App Part 1 - Creating the Database
Traversy Media
Codeigniter App Part 2 - Installation and Configuration
Traversy Media
Codeigniter App Part 6 - Login/Register System
Traversy Media
Codeigniter App Part 7 - Models List CRUD
Traversy Media
Codeigniter App Part 8 - Models Task CRUD
Traversy Media
Node.js Part 1 - Install NodeJS on Windows
Traversy Media
Node.js Part 3 - Building a Static Page Server
Traversy Media
Node.js Part 4 - NPM
Traversy Media
Node.js Part 2 - Install MongoDB in Windows
Traversy Media
Create a Joomla Quickstart with Custom Sample Data
Traversy Media
Install MongoDB in Ubuntu
Traversy Media
HTML5 Web Storage
Traversy Media
Create a Joomla Bootstrap Template From Scratch
Traversy Media
Ubuntu Server 14.04 Setup Part 1 - Installation
Traversy Media
Ubuntu Server 14.04 Setup Part 3 - Set Static IP
Traversy Media
Create A Wordpress Widget - Part 1
Traversy Media
Create A Wordpress Widget - Part 2
Traversy Media
Create A Wordpress Widget - Part 3
Traversy Media
Create A Wordpress Widget - Part 4
Traversy Media
Get Started With Sass on Windows
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 1
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 6
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 4
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 5
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 3
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 2
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 7
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 10
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 8
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 11
Traversy Media
Build An HTML5 Template With Bootstrap and SASS - Part 9
Traversy Media
Build An Audio Player Using HTML5 & jQuery - Part 1
Traversy Media
Build An Audio Player Using HTML5 & jQuery - Part 2
Traversy Media
Youtube Data API v3 & jQuery To List Channel Videos
Traversy Media
Using Bootstrap With Ruby on Rails
Traversy Media
More on: AI Productivity Tools
View skill →
🎓
Tutor Explanation
DeepCamp AI