Basics of Git and using VS Code with Git
Key Takeaways
This video covers the basics of Git and how to use it with VS Code, a popular code editor, providing a foundational understanding for data professionals.
Full Transcript
Hello everybody. In this lesson, we're going to be taking a look at the basics of Git. Now, I have several things open on my computer screen here. First, I have Git Bash open. Go ahead and pull that up on your screen. You should just be able to search for it and open up Git Bash. We looked at how to install Git in the last lesson. So, you should have that installed. Just pull up Git Bash and it should look something like this. Of course, with your information right here. The next thing that I have pulled up and I'm on a Windows is I have my file path. So I have my file folder. I have file paths here. So uh right now we're just in my downloads, but we'll be using this as we go on. And the last thing that I have pulled up right in the background here is Visual Studio Code. Now this is going to be our IDE that we are using in the next several lessons, but you can use any ID and you can connect it. This is just the one that I personally use a lot and I think it really integrates well with Git and GitHub later on in this series. So, if you haven't already, I will leave a link down in the description on where you can download Visual Studio Code. Again, you don't have to use it. You can use any ID that you want, but this is the one that I recommend and I think that most people will be using. So, here's what we're going to do. We are going to take a look at Git and we're going to see kind of where it defaulted to because we just installed it and Git is on our computer, but we haven't done anything to it. We haven't set it up. We haven't kind of customized it to our project. And so, we need to do all of these things. The first thing I'm going to do is I'm going to come right down here and I'm going to say pwd. And this is going to tell us the current file path that it's on. Now, let's come down here and we're going to go to my C drive and we're going to go down to users and we're going to go to Alexf. This is the current drive and there it is. There's Let me pull this up a little more. Now, this is my, you know, C drive on my computer and it just has a bunch of old stuff. This is back when I was creating like uh a lot of Python tutorials and web scraping tutorials. And, you know, as you can see, there's a lot of junk in here. And so, if I come over here and I look at this, I'm just going to say ls. It's going to take a second because it's going to pull in all these files. It's going to pull in all these folders which had a lot of stuff in it. And so, as you can see, this is really messy. There's so much junk in here. Honestly, I should go through and delete a lot of this, but I hold on to it for sentimental reasons, uh, potentially. And what I need to do is I need to either clear this out and make the C drive like really clean, or I just need to create a new folder. And when I'm doing a new project, I usually just create a new folder. So, let's come in here and we're going to do a new folder here. I'm going to call this uh let's call it aa just so that it shows up at the very top because I have it in alphabetical order. We're going to say aa get video series. And so, let's go ahead. Well, we can either refresh right up here and it should show up right near the top at least right here. It didn't show up, I guess, at the top. I have too many other ones. But, we have our AA get video series right here. Let's open this up. And this is beautiful. There's nothing inside of it. This is just it's lovely, right? But we don't have access to this just yet. We need to do something called a change directory. We need to go in here and say this is where we want git to be pointed at. So we're going to do a change directory a cd. And then we just need to put in here this right here. So I'm going to do a control c on this. But when we come in here, it's different for pasting it. We have to do a shift insert. Just like that. Actually, I need to put this in quotes. Uh, but I need to do shift insert. Put that in quotes. And there we go. So now you can see right here there is a new directory and it's pointing at this file path right here. So now we have it in here. But even if we refresh this, there isn't anything in there. What we have to do, especially if you're starting a new project and we're about to start adding files and we're about to start coding and this project's going to last more than a couple days, uh maybe weeks or months, we want to capture all those snapshots of all the code that we're saving and everything like that. So, we need to initialize a repository in here. So, let's go ahead. We're going to say get init. That just means initialize a repository. Let's go ahead and hit enter. It said initialized an empty git repository at this location. So now we have this.getit here which means that we now have an empty repository that we can start adding and committing files to. So it takes those snapshots of the history of this file path. And so if we add files to this, and I'm going to show you how to do that in just a second. We're going to add files. We're going to add and commit them. And then we'll see how we can look at our previous history. So let's do the same thing that we did up here. we did this ls. Let's go ahead and look at ls. And you'll see that there are no files in this file path. Well, let's change that. Let's come right over here and let's go into our visual studio code. Now, what we're going to do is we're going to come up here to explore, but in a second, we're going to come down here to source control. And this is where git is literally integrated into VS Code, which is really, really nice. But first, let's open up our folder and let's go to the project folder that we just created that's in users Alex F and then the AA get video series. So, we're going to add this. And now we have it open, but of course we don't have any files in it just yet. And then if we come right here, you can see that now it is connected. So now we have this master branch right down here connected to this aa git video series. That's because in our folder we have a git repository initiated. So when we connected to that file path within our explorer, it picked up the fact that we are connected to git already and it connects to this. Now this is going to help us a lot. We're not going to use this right now. We're going to do everything within git, but there is a great UI in VS Code that allows us to do a lot of what we're about to do in Git. But I want to take a look at the basics first and then we'll use VS Code after. So what we're going to do is we're going to create a new file. So we're just going to come up here. You can either say controlal alt Windows N or whatever the shortcut is on your computer, but let's go ahead and click on a new file and let's just add a Python file. Let's keep it really simple. So I'm just going to add a comment here. I'll say this is a new file and our first commit. And we're going to go ahead and save this. So you can do Ctrl S. We can save it right in here. And I'm going to rename this. I'm just going to say first file. First file. And let's go ahead and save it. So now we have this file in our folder. And we can see that right here. We have this first file. Now again, there are some things that we're going to look at specifically in VS Code, but we're not looking at that right now. Let's come over here and let's take a look in Git. So now we're going to say ls. Now it's going to read in that first file. It shows that we have a file in it. But if we go and we write get status right here, we're going to get some information. The status basically tells us where things are in the process. Have they already been added to the git repository? And therefore, we can go back and look at them. Have they been added but not committed? So we're going to do that in just a second. We're going to commit this first file. We can see on branch master which this is our master branch. We have no commits yet. We haven't made any commits. So nothing is in our git repository over here. So we have an unttracked file. Our first file py but nothing added to commit but unttracked files present. So this is our unttracked file. So here's what we need to do. We have to do two things. I bled this up just so we can kind of see it. But right here we have to do two things. We're in our working directory. So that's where we're currently at. We have our working directory, but we have to first add it to our staging area. Then we commit it and that's to our local repository. That's our git repository which we can then use to take those snapshots. So let's first use get add and then let's get commit. And let's see how that works. So we're going to say get add. Now, when we get here, you can specify this file path and you can just say first file. py and it's only going to add that file. So, if you have like 20 files in here and you only want to upload the first file py, you can specify that. I don't almost ever do that. I usually just hit period, which means take everything in this file folder and we're going to add that if there have been changes made to that file. So, we've made changes to this file. So, we're going to hit get add everything. And now let's go and hit get status again. And now you can see we have a new file. These are changes to be committed. We haven't committed it just yet, but we are ready to commit this. Once we commit this, it will be stored in this git repo. And again, we can revert back to this. So, let's come in here and we're going to say get commit. Now, don't make the mistake that I made when I was first doing this and hit just hit enter. You can do this, but it brings up this separate UI and so I don't recommend doing that. You can still write your message and everything in there, but um we're going to do dash m, which means here's our message for this commit. So, when you make a commit, you have to have a message. It doesn't have to be a long message. Can be very simple, but when you go back in time and you go to those past snapshots, you can write yourself messages. And so we're going to say this is my first commit. Woohoo. And that's our commit. That's our commit message. Let's go ahead and commit this. It says master root commit. This is my first commit. Woohoo. One file changed one insertion created mode. And then this right here is the file. So now let's look at get status again. And there we go. It says on branch master, nothing to commit. Working tree clean, which means we haven't made any changes to these files in here since the last time that we made a commit. So now that we've made a commit, now we can go and we can look at our log. So I'm going to say get log. And now it's going to show us our previous commits that we have made. And you can see this really long string of numbers and text. This is our hash which we can use to revert back to that snapshot. So this is our kind of a snapshot hash code that you can use. And so this is actually very important. This is what you can use to tell git where to point to when you want to revert back to a previous commit. Now we're not doing that in this lesson, but we'll do it in a future lesson where we'll revert back once we made some changes. So now let's come right over here and let's go back because before and it just got rid of it. But before it said U for unttracked, which means it wasn't tracking anything. And now we can also go into our source control and we can see visually that there is a commit right here. And this is just awesome when you start making a bunch of commits and a bunch of ads and you start branching and merging. This little UI down here is actually really helpful. At least it helps me a lot. Let's do something really quick. Let's come back here and we're going to make a change to this file. So, I'm going to say uh this is our code and I'm just going to make some really ridiculously uh simple code. I'm going to say I love git. There we go. Um and then we're going to save this. Crl S. So now we've saved this file. And now we have a new letter right over here. It says that this file has been modified. And so it's giving us a visual indicator that hey, this has been changed. It has not been saved. So if we go over to our source control, we now see that there were changes made to this first file py. It was modified, but it hasn't been committed yet. So we haven't added this and we haven't committed and it's not saved in our git repo. Now just to make this a little bit even more obvious, we're going to add another file. So again, just add a file. We'll do text file. It doesn't matter. I'm going to say this is a text file for the git series. That's all I'm writing. And we're going to save that. And I'm just going to call this one uh first text file. And we're just going to save it as a txt file. So now that we've added it, now we have this green U. This means it's unttracked. This file has not been saved in the git repo at all. And we need to do that. So again, let's go back to our source control. And now we have a U right here. So you'll notice we have some options under here within our source control for each file. We have open the file, discard these changes, which means we can completely get rid of this, which we can do, or we can stage the changes and then we can commit them. So let's only stage right now this first file. py. Now we have it in two separate sections. One is just there changes have been made. The other is this one has been added to the staging area which again if we come back down here and we look at this by adding it to the staging we just added it right here. We just did the get add but just with a click of a button. We can also unstage the changes or we can add them both. What we're going to do is we're going to make another commit. So now we're going to come up here and let's get rid of this. We're going to make another commit. So, let's commit this. And it wants a message here. And so, I'm not going to do that because that's not typically what I do. I'm going to enter my message right up here. I'm just going to say second commit with updated file. Now, usually with this message, it should mean something. You should kind of indicate what you're doing with it or what you've done, but you know, that isn't super important at the moment. Let's go ahead and commit this. And you'll see right down here, we now have a second commit. So this is our first commit and then right up here this is our second commit. Now look at this thing right here. This is our hash. We can save this or we can copy this using this button. But if we go up that hash has completely changed. And it's also noted that this was saved who it was, where it was saved and what that commit message was. It also will tell us that one file was changed, six insertions and one deletion. So, gives us some information and again that's something we'll look at in a future lesson about how to look at those differences. But if you'll notice up here, we didn't commit this one and that's cuz we never added it to the staging. So, let's stage this. Let's say this is our third commit with text file. And let's commit this. And now we have three commits. Our first commit, our second commit, which I misspelled with. Uh that's that's a shame. And then we have our third commit. Now, these are all on the master branch, right? But in a future lesson, we can create separate branches within our GitHub repository, and that's going to totally change the game and how we do our workflow and a few other things. And we'll get to that in a future lesson. So, we now have these three separate commits. And in the next lesson, what we're going to look at is how we can revert back to these previous snapshots or commits. So, I hope that that was helpful. I'm super excited for this series because we're going to be connecting this to GitHub. We're going to be see we can update things and we can clone repositories and a bunch of other things. So, I'm super excited. I hope this is really helpful to you guys. If you like this video, be sure to like and subscribe and I'll see you in the next video. [Music]
Original Description
Take my Full Git and GitHub course: https://www.analystbuilder.com/courses/git-and-github-for-data-professionals
VS Code: https://code.visualstudio.com/
____________________________________________
RESOURCES:
💻Analyst Builder - https://www.analystbuilder.com/
📖Take my Full MySQL Course Here: https://bit.ly/3tqOipr
📖Take my Full Python Course Here: https://bit.ly/48O581R
📖Practice Technical Interview Questions: https://bit.ly/46pDqqL
Coursera Courses:
Google Data Analyst Certification: https://coursera.pxf.io/5bBd62
Data Analysis with Python - https://coursera.pxf.io/BXY3Wy
IBM Data Analysis Specialization - https://coursera.pxf.io/AoYOdR
Tableau Data Visualization - https://coursera.pxf.io/MXYqaN
Udemy Courses:
Python for Data Science - https://bit.ly/3Z4A5K6
Statistics for Data Science - https://bit.ly/37jqDbq
SQL for Data Analysts (SSMS) - https://bit.ly/3fkqEij
Tableau A-Z - http://bit.ly/385lYvN
*Please note I may earn a small commission for any purchase through these links - Thanks for supporting the channel!*
____________________________________________
BECOME A MEMBER -
Want to support the channel? Consider becoming a member! I do Monthly Livestreams and you get some awesome Emoji's to use in chat and comments!
https://www.youtube.com/channel/UC7cs8q-gJRlGwj4A8OmCmXg/join
____________________________________________
Websites:
💻Website: AlexTheAnalyst.com
💾GitHub: https://github.com/AlexTheAnalyst
📱Instagram: @Alex_The_Analyst
____________________________________________
*All opinions or statements in this video are my own and do not reflect the opinion of the company I work for or have ever worked for*
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Alex The Analyst · Alex The Analyst · 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
Top 3 Data Analyst Skills in 2020
Alex The Analyst
Truth About Big Companies | Told by a Fortune 500 Data Analyst
Alex The Analyst
Data Analyst Salary | 100k with No Experience
Alex The Analyst
Working at a Big Company Vs Small Company | Told by a Fortune 500 Data Analyst
Alex The Analyst
Data Analyst Resume | Reviewing My Resume! | Fortune 500 Data Analyst
Alex The Analyst
Data Analyst Resume | Complete Guide To Creating A Data Analyst Resume | Tips + Templates + Examples
Alex The Analyst
Switching Careers to Become a Data Analyst | How I Made the Switch
Alex The Analyst
Working With a Recruiter to Land Your First Job as a Data Analyst | LinkedIn Recruiters
Alex The Analyst
Data Analyst Salary in 2020
Alex The Analyst
Data Analyst Resume | Reviewing YOUR Data Analyst Resumes!
Alex The Analyst
Data Analyst Fact Check | 84k Average Starting Salary?? | The Career Force 2020 Data Analyst Salary
Alex The Analyst
SQL Basics Tutorial For Beginners | Installing SQL Server Management Studio and Create Tables | 1/4
Alex The Analyst
SQL Basics Tutorial For Beginners | Select + From Statements | 2/4
Alex The Analyst
SQL Basics Tutorial For Beginners | Where Statement | 3/4
Alex The Analyst
SQL Basics Tutorial For Beginners | Group By + Order By Statements | 4/4
Alex The Analyst
Day in the Life of a Data Analyst | Fortune 500 Edition
Alex The Analyst
Intermediate SQL Tutorial | Inner/Outer Joins | Use Cases
Alex The Analyst
Intermediate SQL Tutorial | Unions | Union Operator
Alex The Analyst
Intermediate SQL Tutorial | Case Statement | Use Cases
Alex The Analyst
Intermediate SQL Tutorial | Having Clause
Alex The Analyst
Intermediate SQL Tutorial | Updating/Deleting Data
Alex The Analyst
Day in the Life of a Data Analyst | Fortune 500 Edition (During Quarantine)
Alex The Analyst
Data Analyst Interview Questions | Phone + In-Person Interview Questions
Alex The Analyst
SQL Interview Questions and Answers for Beginners | Data Analyst Interview Questions
Alex The Analyst
Data Analyst Interview Questions | What To Say vs What NOT To Say
Alex The Analyst
Data Analyst Interviews | Salary Negotiation
Alex The Analyst
Data Analyst Q&A LIVE
Alex The Analyst
Intermediate SQL Tutorial | Aliasing
Alex The Analyst
Data Scientist vs Data Analyst | Which Is Right For You?
Alex The Analyst
Best Online Courses for Data Analysts
Alex The Analyst
Best Free Online Courses for Data Analysts
Alex The Analyst
Data Analyst vs Business Analyst | Which Is Right For You?
Alex The Analyst
Scraping Data Off Twitter Using Python | Twitterscraper + NLP + Data Visualization
Alex The Analyst
Data Analyst Question and Answer | Answering Your YouTube Questions
Alex The Analyst
What Does a Data Analyst Actually Do?
Alex The Analyst
Data Analyst Bootcamps | Are They Worth It?
Alex The Analyst
Top 5 Reasons Not to Become a Data Analyst
Alex The Analyst
Data Analyst Career Path | How to Become a Data Analyst + What to Do Next
Alex The Analyst
Live Data Analyst Q&A #3
Alex The Analyst
Top 5 Reasons Not to Lie on Your Resume
Alex The Analyst
The Hiring Process from an Interviewer's Perspective | Alex The Analyst Show | Episode 1
Alex The Analyst
Top 5 Reasons Data Analytics is a Good Career Choice
Alex The Analyst
How I Changed Careers to Become a Data Analyst | Alex The Analyst Show | Episode 2
Alex The Analyst
Top 5 Reasons You'll Be a Good Data Analyst
Alex The Analyst
Self Taught vs Boot Camp vs Degree | Alex The Analyst Show | Episode 3
Alex The Analyst
Covid and the Data Analyst Job Market | Alex The Analyst Show | Episode 4
Alex The Analyst
Data Analyst Expectations vs Reality
Alex The Analyst
Imposter Syndrome in Tech | Alex The Analyst Show | Episode 5
Alex The Analyst
Top 10 Coursera Courses for Data Analysts
Alex The Analyst
Working at a Startup vs Fortune 500 Company | Alex The Analyst Show | Episode 6
Alex The Analyst
Data Analyst Certifications | Are They Worth It? | Alex The Analyst Show | Episode 7
Alex The Analyst
Top 10 Udemy Courses for Data Analysts
Alex The Analyst
Asking My Wife Your Questions About Me | Alex The Analyst Show | Episode 8
Alex The Analyst
Data Analyst Q&A LIVE #4
Alex The Analyst
Data Analyst Skills Path | What Skills You NEED to Know
Alex The Analyst
What is Analytics Consulting? With John Ariansen | Alex The Analyst Show | Episode 9
Alex The Analyst
Solving LeetCode SQL Interview Questions | Part 1/3
Alex The Analyst
What is No Code Analytics? | Alex The Analyst Show | Episode 10
Alex The Analyst
Top 3 Tips on Using LinkedIn to Land a Job
Alex The Analyst
Completely Unrealistic Jobs on LinkedIn | Alex The Analyst Show | Episode 11
Alex The Analyst
More on: Tool Use & Function Calling
View skill →Related Reads
📰
📰
📰
📰
The Who, What, and Why of Semantic Layers: The Layer That Decides Whether Your Numbers Can Be Trusted
Dev.to · Alex Merced
Data structures — Hash tables/ Associative Arrays
Medium · Python
Why Revisiting Old Databricks Concepts Made Me a Better Learner
Medium · Data Science
Day 96: Data Catalog Service - AI System Design in Seconds
Dev.to · Matt Frank
🎓
Tutor Explanation
DeepCamp AI