Git Video Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
well hello Internet and welcome to my git video tutorial this is going to be a big tutorial because I'm going to show you how to install git on Windows and Mac and Linux pretty much and I'm also going to show you all of the common commands you will need to use git I'm going to do my best to cover everything part of it's going to be presentation and part of it's going to be in a terminal and I'm going to go as fast as possible so let's get into it so you may be asking yourself probably not though what is git well git is a Version Control tool that saves changes to group of files so you can revert back if needed and no this whole entire presentation isn't going to be in this format most of it's going to be in the terminal but I just wanted to start off this way now there are different types of Version Control tools there's local Version Control which saves files to a database on one computer there's centralized Version Control which saves changes to a shared server and then there's distributed Version Control which allows for easier sharing of files then you're going to find with local Version Control because you're going to be able to share them and also it eliminates problem that could occur if access to the server is lost under a centralized version control system now DVC clients that are using git are going to have complete backups of all the files on their personal computer so if the server is lost the client just waits to regain contact and then uploads changes whenever it's available what this means is when you commit changes to files get basically stores of reference of what the files look like at that moment and if a file isn't changed it isn't stored again and like I said before for each client is going to have a complete history of all changes stored locally and the client also is going to be able to access all changes made to those files historically with just a couple simple commands another benefit is those files cannot be changed without get knowing and changes are very difficult to lose now basically in git files transition between three different states they're going to be either be modified files which are files that have been recently changed staged files which have been marked to be saved and committed files which are those that have been saved okay so it's modified staged committed get saves all these file changes to a directory as a compressed database and then you're going to be able to modify those files in what is called a working directory you then can notify that you want saved changes in the staging area and then of course after you commit the file changes they are saved to the git directory now if you want to install get here you go I'm going to show it to you step by step but basically these are going to be the addresses you're going to have to go to and of course I provide a link underneath the video and of course in Linux you can just type in a couple simple commands either one of these should work for you depending upon what type of Linux you are using so enough of that presentation format let's install git on Windows okay so basically inside of Windows we're going to go to this address and this is going to be the site that you're going to see of course hit download and then you're going to see get show up down here you're going to have the security warning pop up of course hit run another security popup comes up of course hit yes and then you're going to be able to set up get of course come down here and hit next you're going to get to see the license again hit next then you need to Define exactly where you want to save everything I just hit next and then here I check that I want both the git bash this guy right here as well as the get goey and then of course hit next then this pops up hit next again I prefer to select the first option right here because I'm just going to use get bash because I will like to use the commands that are provided there again I leave the first option checked again and hit next and then everything's going to install for you and then the wizard pops up and everything's installed and I check on that I don't care about the release notes and hit finish now to open up git you're going to click on your start button and then look for a folder named git and specifically click on get bash and here you can see an example of what I have set the very first thing you're going to want to type in is get config D- Global username and then put your name inside of here and that's going to allow you to track who has changed files inside of your database you're also going to want to come in here and Define a user email as you can see there's mine so just type that in and of course hit enter again and then the final thing that I wanted to bring up because I'm going to do all this stuff live in front of you but I'm going to do it over on a Mac all the commands are exactly the same the only thing that I wanted to point out here is if you want to change your directory this is something that comes up all the time and there is a space in the directory name just surround them with quotes Okay so now I'm going to show you how to install git on a OSX or Mac computer okay so we're going to go to sourceforge.net projects blah blah blah again this Link's going to be in the description then you're just going to want to come down here and click on download then you're going to want to open up the file that was downloaded and double click on this box right here then your installer is going to open up of course click on continue again click on install and the installation was successful and now of course just like you did inside of Windows you're going to want to come in here and type get config D- Global username and then your name inside of quotes and then also I came in here and also defined the email address again get config -- Global user email and then whatever your email address is now one thing that you might want to do is to edit what are called commit messages which is basically just a message about why you changed the file or how you changed it or whatever well one of the things that a lot of people on Max like to do even though I never do it is to use a chosen text editor in this situation I'm using text Wrangler because I use it and uh if you want to use text dangler instead of using the inline editing tools that are common or default inside of git what you're going to need to do in text Wrangler is click on text wrang Strangler and then click on install command line tools and whenever you do this little popup is going to pop up on your screen click on okay and then to use text Wrangler in this situation all you're going to need to do is type in get config D- of course this is inside of the terminal on your Macintosh or OSX machine you're going to type in get config D- Global core. editor and then inside of quotes edit space- W and of course I have a link also to the entire transcription of this video underneath the video okay so enough of the presentation format let's jump in and start using get okay so here I am inside of the terminal and like I said before all the commands you see here are exactly the same on every operating system I'm just using this mainly because I'm recording everything here and it's easier on my computer now I just showed you how to change over to use text Wrangler for your chosen editor and you're going to see in a second what I mean by editor and here we're going to come in and I'm going to change it over over to Vim which is very commonly used so I'm going to go Global core. editor and then I'm going to type in Vim instead and whenever I do nothing's really going to happen it's just going to use that editor from now on now if you want to show your settings because we just changed a whole bunch of settings here all you need to do is go get config and then Dash Dash and list and there you can see all the information that I changed inside of here if you ever need to get help just type in get help pretty easy and of course you're going to see all the different things you can get help on and then let's say for example you want to specifically get help on ad all you would do then I'm going to clear the scroll back is just go get help add and it's going to show you all that information and you can read through it all that you would like and you just type quit or cue to get out of that and if you're on a Windows computer and you want to clear the scroll back just type in clear and hit enter that works as well now if you want to start tracking a directory what that basically means is you want to start saving certain files F inside of a folder or a directory on your computer the very first thing you're going to want to do is actually go to that directory okay and I'm going to use an Android directory here just to change the files it doesn't really matter what you use however and you're just going to type in whatever that directory is and let's just do this and then if you want to show everything inside the directory either type in LS and you're going to show everything like that or you can type in ls- a and that's going to show everything and show a lot of things that are hit like this stuff right here but either way let's clear the scroll back and in this situation what I want to do is I want to use a directory called first app so change directory first app and I'm inside of it and I hit LS you can see all this stuff right here and then if I want to tell get hey I want you to start saving certain files inside of this directory all I do is type get and knit and there you can see initialized empty get repository there's nothing inside of it right now if you want to start tracking specific files you can do that in a coup couple different ways let's say that you wanted to track changes in every single Java file you could just go get add well if you wanted to do everything you just type in Star if you want to type in just specifically Java files even though there aren't any on here right now you would just type get add star. Java to right click that and it's going to automatically add all those um I'm going to use a specific file in this situation which is going to be Android manifest that's what I'm going to be working with so if I want to start tracking it and saving change I just type in get add Android manifest XML there you can see doesn't show you any message if I want to specifically ignore certain files what you want to do I'm going to do this right now is you want to create a file called Dog git ignore like like that if you can see that right there and then you're going to want to basically what I do is I just take all the different file types that I think I'm going to be working with and I go to a website and automatically download all these different things so common things that you would want to ignore if you're developing Android is all this stuff and you can see it's going to ignore all APK files it's going to ignore all Dex files all class files it's going to ignore the bin and gen folder or directory and all of these different things so you can see right here an example of all that I'm going to show you the website let me just jump over you can see it right here it's github.com for SL GitHub slgi ignore and if you go here you're going to see all of the common things that should be ignored normally are ignored inside of git but of course you can also ignore very specific file names just like I added the Manifest that you just saw so let's jump back over in the terminal and keep playing around with this all right so what you're going to want to do is save this file so I'm going to go save as and where am I going to save it well I saved it as first app there we go and I'm going to save it inside of here and again it's get ignore right like that and that's going to save you a lot of time in regards to worrying about things if you're on a Mac it might give you a warning just say use dot okay and there we go now we have all of the files that we should ignore ignored okay so back in the terminal and you can also go LS and you're going to see that the ignore well the ignore file didn't show up let's clear scroll back and let's go ls- a and now you're going to see get ignore is right there okay now if I want to commit the Android manifest XML file that I just typed in there that I wanted to Stage is what they call it I'm going to show you a brief way to do it and I'm going to show you a more complicated way to do it you just type in get commit and then if you want to write directly to it without opening up an editor you're going to type in dasm and then I'm going to give this a note like initial project version okay right like that and there you're going to see that everything went through and an editor didn't pop up that's going to going to change here in a second and I just want to point out if you ever want to do an abbreviated what it's called as a commit message or commit comment you just type in commit DM after that more than likely you're not going to want to do that all the time because it's going to make your changes a lot harder to figure out for other developers as well as yourself now if you want to get the status on all of your files you just type in get status right like that you're going to see all of the different untracked files that you have have here and there's going to of course be some missing because you're ignoring some of them and now I'm going to go through the process of staging a file basically I'm going to open up Eclipse right like this and I'm going to open up a very specific file open file and I'm going to find first app which is going to be right here and let's just come in here and first app is right there and you're going to see Android manifest which is one of the files that I'm going to be tracking so I'm just going to double click on that and I'm going to come in here and make a completely inconsequential little change to this file I'm going to put a comment inside of it so I'm just type in this and you can save images with Git You can save any file that you would want okay so I'm just going to type in random comment inside of it random comments whatever and I'm going to save this so file save now I'm going to jump back over inside of the terminal inside of git clear the scroll back again and then this is what's called staging so basically I'm going to Stage this file and then it's going to be committed and there's going to be two different versions on the get system so if I want to show what has changed one thing that I can do is go in here and go get diff and I provide a cheat sheet as well under in the description you can see right here where we have the plus sign right here and random comments it shows me exactly right here exactly what has been changed inside of there so that's very good and very useful if however I want to actually stage this file which means that I plan on committing it very soon thereafter I'm just going to go get just like I showed you before I'm going to type in Android manifest.xml and this file has now been staged and you can see that if I come in here and go get diff D- catched like this that it's going to show exactly what has been staged and what has not been committed on our screen now the logical thing to do is to just commit the changes so you type get commit and there you can see what actually happened is a file opened up on your system and I'm using Vim is very easy to use very first thing I'm going to do is I'm going to type Escape or I'm hit or I'm going to hit my Escape key already was escaped and then I'm going to hit I you're going to see down here in the lower left hand corner that insert popped up then inside of here I'm going to note exactly what I changed now everybody's kind of a stickler for what exactly how these are formatted basically what I'm going to do is I'm going to cover the most common way of commenting on a commit change or a change to this file basically you want to type in a heading that briefly explains the changes in 50 characters or less so let's just say client asked me to change a comment okay that's terrible but that's pretty much what I did so what I'm going to do here is I'm just going to type in that's sort of like a heading then what I'm going to do of course in the real world you would type in exactly the problem that you very specifically changed or the exact change that you made but I'm sure you understand that then what you're going to want to do is in sort of a paragraph format is describe the original problem that was addressed then you're going to want to describe the specific change that is being made right here then you're going to describe the result of the change or the result that you know you're going to have and then you're going to potentially describe any future improvements and then you could type in like a bug not notation or something like that as well so let's just say um the client asked for the comment to be add added da da da da and then I normally well I never go past this line right here it causes some problems with the terminal sometimes so I made that and then I'm going to hit enter change for them and then all the things that I told you you should also do another thing you is very common is to also come in here and type in a star and then type something like client asked for comment change and then you could say you know bulleted list of what you did I don't W see this affecting anything okay and then you could do something like come in here and add a bug notation which basically means that you've closed a bug and bugs normally have numbers and then you could type something like number sign and 129 1621 or something you know whatever the bug number is and then hit enter make sure that you do that again then what you need to do is hit escape again the Escape key and then down here at the very bottom you're going to type in a Col and WQ and that is going to save the changes that you just made and then of course hit enter and there you go and you can see right here the notation you can see right there that your file has been changed another thing that you could do if you want to totally skip the staging as well as the commit message that we just typed in that was a commit message is just type get commit and then type A that's going to skip the whole staging area you're not going to have to do the adding and all that and then of course you can type in- M and you can type in exactly what you want to change here so let's jump over and let's actually change the file slightly go into the comment section and I'm just going to type two inside of there and then I'm going to type in save again there we go I changed it and then here I'm going to say changed comment added to whatever and there we can see that the comment was changed and everything's there on the screen so that's a shorthand way of both skipping the staging as well as skipping the commit message but like I said just something you're not really going want to do all the time cuz the whole idea here is to be able to track all your changes and be able to very logically figure out any errors that might have been added along the way and now what I'm going to do is actually create a file so that you can see exactly how to remove a file inside of git so I'm just going to go file new text document and I'm going to say please delete me and then I'm going to go file save as you can see I'm right here in the same place and I'm just going to call this delete me text hit save back over and get again and there you can see delete me text is right inside of there now I'm going to type in get add and delete me text right like this and then if I want to remove it I can type in get RM delete me. text and you're going to see the message pop up that it is in the staging area and cannot be deleted unless you do a force removal so no problem just come in here rim and then I'm going to type in-hf and there you can see that it was deleted and if I type in LS you're going to see it's deleted as well another thing you could do is let's go and save that again file save as Pop back over here LS you're going to see delete me is back there again see there's delete me and this time let's say that you just want to remove it from the staging area you can just go get add and I'm going to put it in the staging area right like this and then if I want to remove it from the staging area I just go get rm-- catched delete me text and this is going to keep the file on your system but it's going to remove it from the staging area and there you can see if I type LS delete me still there but it's not going to be in the staging area get status and there you can see that it's not in the staging area now what I want to do is come in here and go get add and delete me text then I'm going to go get commit DM initial project version and now if I want to rename my file I can go get MV delete me text and rename it to delete text or something like that and get status and you can see right there that it was renamed now let's take a look at logs and how they work inside of G now if you want to show all the previous commit messages in reverse chronic logical order just type in get log and there you can see all of the different changes that were made as well as all the different notifications just type in Q and then you'll jump out of that and then I'm going to clear my scroll back if you want to show all of these on one line this is very common you just go get log D- pretty equals one line and there you can see everything's pretty easy to see the only problem is this is kind of a mess we want to shorten that maybe so let's go get log pretty again but this time we're going to format exactly how this information shows on the screen so let's just come in here if I want to just show like an abbreviation of this hash code right here I just type in percent and H and then let's say I want to put a coal in between there I can do another percent sign and if I want to show the person that made this change I can just type in percent a and another colon you don't need these colons you can put anything inside of there I just chose to use colons a is going to be the date that was changed and then if I want to show the first line of the comment I just put percent s right like that hit enter you can see got exactly right there on the screen exactly what I wanted it's so pretty neat there's a couple other codes that I'll get into later in this tutorial but for now I think that's enough another thing is if you want to say show just the last two commits you can come in here and and let's say I type in p and if I just want to see the last two there you can see all those are on the screen right there for me hit Q to jump out of that again if I want to print just some what are called abbreviated stats I can just come in here and go stat and there you can see that on the screen just a whole bunch of different things you can do if you want to see all the changes in the last week well this in this situation it's going to be everything but get log you're going to type in Das Dash since equals and then you can type in one. weeks and I'll show you a couple other things there's everything C to jump out of that again you can also get all the changes since a specific date so let's go get log again this is going to be everything since I just did all this right here in front of you since is equal to and that's how I want to do 2014- 04-12 that's going give me everything there you can see there's everything again you can also format all this information I can also just show the changes that have been made by a specific author there you go and I'm just going to say dark Banus whoops make sure I spell that right bis and there's all the changes I have made Q jump out again if I want to see all the changes that were made before a certain date get log before is equal to and then 2014- 04-13 and there you can see there again and then in this situation let's say that I want to make another file change so let's go to that you can see that it's listed as delete text right there delete me um I'm just going to type in again and file save that let's say that come in here and I go get add delete text and then I go commit whoops make sure you type in get every time get commit and then type in m and just I don't know random change you would never want to type this in in the real world but I'm to to type it in here and there you go let's say that you wanted to undo a commit all you do is type in get commit Das Dash amend and this is going to allow you to change your previous commit that you just made right there and you can see right here if I typed in something ridiculous like that well I can come in here and change it I'm going to change into insert mode by hitting I and then I'm going to delete this delete the whole thing here and type in something much better typed in random message there you go that's much better escape again hit the colon WQ see right down here there's WQ okay and then hit enter and then the final thing that I'm going to cover in this tutorial later on well maybe in the ne probably in the next tutorial I'm going to cover remote and using remote files because I just couldn't fit all this in one tutorial it's just an insane amount let's say if you came in here and you said that you wanted to Stage a file by going get add again and delete text right like that let's say that you went and staged the file but then you decided you did not want to Stage it well you just type in reset head and then in this situation you're going to type in what you want to on stage and there you go and you type in get status and there you can see that it is not ready to be committed so there is a time of things about git hopefully I answered a lot of your questions again I'm going to cover I'm trying to cover everything as quickly as humanly possible so and of course there's cheat sheets and all that stuff underneath the video to help you along it's pretty easy to use you just have to dive in and start using it and of course it is extremely useful I just wanted to make a special note right here if it is before April the 25th of 2014 I'm giving away another Samsung Galaxy Note 3 with a Samsung Galaxy Gear Smartwatch in this part of the contest all you need to do is to submit on my website a link to a funny video that shows why you should win emphasis on funny and whoever makes the funniest video is going to win so please leave your questions and comments below otherwise till next time
Info
Channel: Derek Banas
Views: 319,644
Rating: undefined out of 5
Keywords: Git Video Tutorial, Git, Git Tutorial, Installing Git, GitHub Tutorial, GitHub
Id: r63f51ce84A
Channel Id: undefined
Length: 25min 15sec (1515 seconds)
Published: Mon Apr 14 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.