Learn Git and GitHub in 1 Hour!
By Alex The Analyst
Summary
## Key takeaways - **Git vs GitHub Distinction**: GitHub is a service and cloud-based hosting platform owned by Microsoft, while Git is the actual distributed version control software that runs locally on your machine via command line. GitHub sits on top of Git to provide a user interface for collaboration, code reviews, and remote storage. [07:31], [08:36] - **Version Control Snapshots**: Version control works like video game save points, taking snapshots of code changes so you can view history, roll back to any previous snapshot even after weeks or months, and avoid losing work. Without it, you may not recover if files aren't saved properly. [01:32], [02:33] - **Git Created by Linus Torvalds**: Git was created by Linus Torvalds, who also made Linux, because he faced issues with Bitkeeper including conflicts in simultaneous developer work. Git introduced distributed version control that's fast and excels with large codebases or databases. [02:57], [03:51] - **Branching Prevents Overwrites**: Git's main branch acts as the source of truth, but you branch off to code alongside it without overwriting others' changes, then merge back with reviews. This allows multiple developers to work simultaneously on a project. [04:15], [04:48] - **Git Workflow: Add, Commit, Push**: Use 'git add .' to stage all changes, 'git commit -m "message"' to snapshot them locally with a descriptive message for history, then connect to GitHub remote with 'git remote add origin' and push. Status shows untracked, staged, or committed files. [23:52], [25:39] - **Pull Requests for Merging**: On GitHub, create a pull request from a feature branch to compare changes with main and merge after review, unlike local Git where you merge directly. This approves code and resolves conflicts if files changed in both branches. [47:09], [52:26]
Topics Covered
- Version Control Like Video Game Save Points
- Branching Prevents Code Overwrites
- Git vs GitHub Separate Tools
- Pull Requests Approve Merges
Full Transcript
What's going on everybody? Welcome back
to another video. Today we're going to be learning Git and GitHub in under an hour.
[Music] Now, if you were like me many years ago, I only knew what GitHub was. I just used it to toss projects into and link it to LinkedIn or maybe X or Twitter. I did
not start using Git and GitHub professionally until about four years into being a data analyst. To be honest, I was very intimidated. I did not know anything about version control. It was
very scary to me. Luckily, I had some good people on my team who were very patient with me, but it did take me a while to learn. And so hopefully in this lesson, you're going to learn Git and GitHub really well very quickly. Now,
what we're going to be doing in this video is we're going to start off by comparing Git and GitHub because believe it or not, they are two completely separate tools. Next, we're going to
separate tools. Next, we're going to install Git. We're going to spin up a
install Git. We're going to spin up a repository. We're going to make some
repository. We're going to make some commits and then we will be connecting that to GitHub. After that, we're going to kind of get into a full life cycle of what it's like actually using these tools. We will be connecting this to VS
tools. We will be connecting this to VS Code. I use that a lot when I was in my
Code. I use that a lot when I was in my job, and I think it's a really popular IDE for people to use these tools with.
I really hope you learn a ton in this video. If you want to dive even more in
video. If you want to dive even more in depth, I have a full course on Git and GitHub on my platform, analystbuilder.com. I will leave a link
analystbuilder.com. I will leave a link in the description. Without further ado, let's get started by taking a look at the difference between Git and GitHub.
All right. So before we get into Git and GitHub, a really important concept to understand is version control. Now
version control has a lot of depth to it, but I'm going to give you some of the basics of what version control is.
The way that I look at version control is basically like a video game. You can
have save points previously and you can go back to those save points and then you can play the game from there and if you want to go back, you can. And that's
kind of how version control works. It
takes snapshots of changes you make except instead of a video game it's when you're coding. Say you're coding today
you're coding. Say you're coding today and you take a snapshot and then in a week you take another snapshot and then another week you take another snapshot but then at the very end you realize a while back several weeks ago you did
something wrong and you need to go back.
Without version control you may not be able to do that. You may not have saved your files appropriately. But with
version control you can just revert back to a previous snapshot and then you can start working from there. And it's a really great system. So it takes snapshots of changes. You can view your history. So if you take lots of
history. So if you take lots of snapshots, you can go back and you can see where you took those snapshots. You
can also roll back your changes. So like
I said, if you've been coding for a week, a month, a year, you can go back to any of those previous snapshots. The
next thing to know is that version control systems allow for collaboration.
Now with Git, it's going to be on your local machine. But when we connect it to
local machine. But when we connect it to something like GitHub, then you'll be able to collaborate with a team. People
can clone your repository. They can pull everything and all the changes that you've made in your GitHub and it becomes a great way to share your code and collaborate with other people on your team. So with that being said,
your team. So with that being said, let's take a look at Git. So Git was created by Lionus Tolv. If you don't know who that is, he created the Linux operating system, which is pretty
awesome. But he created git because he
awesome. But he created git because he was running into so many issues with something called Bitkeeper which is what which is what the previous version control system was for Linux. And so Git introduced distributed version control
which allows lots of developers to work on a project simultaneously without conflicts. Again, one of the issues that
conflicts. Again, one of the issues that Bitkeeper had. The other biggest thing
Bitkeeper had. The other biggest thing is that Git is really good at working with large projects and is really fast.
And so if you have really large databases or really large code bases that you're working with, Git handles them extremely well. So that's who created it. That's kind of why it was
created it. That's kind of why it was created and a little bit about what it does. But let's take a look a little bit
does. But let's take a look a little bit more into what Git really is. Git is a distributed version control system, a VCS. And like we talked about with
VCS. And like we talked about with version control systems at the very beginning, it allows you to track changes in your source code while you're developing things. Now this was
developing things. Now this was originally created for software development but other teams use it too.
When I was back on a data science team we use Git and GitHub and that was very common. So a lot of data science data
common. So a lot of data science data engineering they will use Git and GitHub in their workflow. It's not just for software development anymore. Git allows
multiple developers to work on a project without overwriting each other's changes. And so what you have is you'll
changes. And so what you have is you'll have this main branch that is kind of your source of truth. And then what you can do is Git allows you to branch off of that. and basically code alongside
of that. and basically code alongside that main branch. And then when you're done, you can merge it back into that main codebase with reviews. And that way it doesn't overwrite someone else's code
because you're not all coding on the same main branch. Why do people use Git specifically? Well, Git is one of the
specifically? Well, Git is one of the most popular version control software in the entire world. In fact, it comes pre-installed on Mac and Linux. It does
not come pre-installed on Windows, but in the next lesson, I'll show you how to download that and get that set up. The
other thing is that it's open source.
Anybody can use it. Git is completely free to use. Just a local application that you can run and use. And honestly,
it's quite easy once you get into it.
The next thing is it has lots of documentation and support. I've run into issues when I've used Git. And there's
so much documentation on exactly how to fix these issues. It is insane. And so
any issue that you could possibly have has most likely been encountered and you can just find out how to fix it online.
And lastly, Git has integrations with almost all version control systems like Source Tree, Heroku, and GitHub most popularly, but you can integrate it with a ton of different applications. On this
right hand side, this is kind of a workflow of Git. We'll be working through some of these things in this series where I show you how you can create a local repository, how you can create a remote repository, how you can
work with those two together, how to add, commit, and push, how to pull down your changes, how to push your changes.
All these different things are things that we'll be looking at in this series.
Next, let's take a look at GitHub. Now,
believe it or not, Git and GitHub are not the same, and they're not even owned by the same company. GitHub was founded in 2008 and quickly became one of the largest code host websites in the world,
and absolutely changed how coders and developers and data professionals collaborate and work on coding. It was
acquired in 2018 by, you guessed it, Microsoft for over $7 billion. So it
gives you a little indication on kind of the value that GitHub was providing and the fact that Microsoft acquired it which is one of the biggest tech companies in the world. GitHub is
basically just a hosting website for Git. It adds some additional
Git. It adds some additional functionality which makes using Git a lot easier and so that's why so many people use it. But GitHub can also be free and you can host your open source
projects and even private projects. But
there is a paid version where larger teams can pay for it. It does get a bit pricey. For my team with Analyst
pricey. For my team with Analyst Builder, we use GitHub and we have the paid version. It is pricey, but it is a
paid version. It is pricey, but it is a very great service. So, GitHub is basically a cloud-based platform to kind of connect to Git and store things in the cloud. So, you can access it
the cloud. So, you can access it anywhere in the world. If you're using a local Git repo, then you can only access that on your local machine. You can't
access that if you go to another computer. So, GitHub utilizes Git for
computer. So, GitHub utilizes Git for their version control, which is how they track the changes and maintain the different versions of their code. So,
GitHub is basically built off of and utilizes Git. And GitHub really makes it
utilizes Git. And GitHub really makes it easy for teams to work together because like I said, you can pull down different changes, you can merge things, you can have code reviews, and you can do all that within GitHub. And it makes it
really easy with a great user interface.
So, really quickly, let's just take a look at the difference between Git and GitHub. GitHub is a service, whereas Git
GitHub. GitHub is a service, whereas Git is the actual software. GitHub basically
just sits on top of it in the cloud and utilizes Git. GitHub is kind of the user
utilizes Git. GitHub is kind of the user interface, while Git is a command line tool. You're going to use it in the
tool. You're going to use it in the command line. And that might seem a
command line. And that might seem a little bit scary to you at first because maybe you've never done that before, but I'll show you how to do it. It's a lot easier than it sounds. Next is that GitHub is hosted on the web. It's a
cloud-based service, whereas Git is stored locally on your machine. GitHub
is maintained and owned by Microsoft, while Git is maintained and owned by Linux. Next, GitHub is focused on
Linux. Next, GitHub is focused on centralized source code hosting, while Git is focused on version control and code sharing. And lastly, GitHub is a
code sharing. And lastly, GitHub is a host service for Git repositories, while Git is the version control system that manages your code history. I think this sums up basically I think this sums up perfectly kind of the differences
between the two and where you're going to use them. Honestly, when you're working on a project on your local machine, you should be using Git for the most part. But then when you want to
most part. But then when you want to save and store and share all these different things, you're going to connect it to GitHub and then use that platform to kind of disperse, save, and have that history of your code online.
Hello everybody. In this lesson, we're going to be downloading and setting up Git and GitHub. And so I'm going to show you how you can do both. And then in the next lesson, we're going to dive into
Git. And then in future lessons, we'll
Git. And then in future lessons, we'll be combining both Git and GitHub, and we should learn a ton in this series. Now,
if you're already on Mac or Linux, go down and search and see if you already have Git pre-installed because Git should come pre-installed on both those operating systems. If for whatever reason you don't have it, you can
install those here, but I'm on a Windows machine, so I'm going to download Windows because if you are on Windows, you will not have Git pre-installed at all. It just does not come
all. It just does not come pre-installed. So, let's download for
pre-installed. So, let's download for Windows. We're going to click here to
Windows. We're going to click here to download. Now, we have to save this
download. Now, we have to save this somewhere. I'm just going to go to my
somewhere. I'm just going to go to my downloads and save this in here. There
we go. Let's go ahead and save this.
And there we go. There's our .exe file.
Let's go ahead and click on it. So, now
we get this popup. And this is the git setup. And it's very, very simple. So,
setup. And it's very, very simple. So,
let's just walk through it. Let's go
ahead and click next. We need to specify where we're going to keep this. I am
going to keep this in my program files.
So, I don't need to change that location. Next, we need to select the
location. Next, we need to select the components. Now, there are ones already
components. Now, there are ones already pre-installed.
If you are going to be using Git a ton, you can check for daily updates, but I'm not going to do that. I'm just going to go ahead and click next. We can also create a shortcut if you want to access
Git. I don't want this on my start menu,
Git. I don't want this on my start menu, so I'm not going to do that. But if you want to, you can go ahead and have that.
And let's click next. This one is very important. Choose the default editor,
important. Choose the default editor, use by Git. Now, it says use Vim's the ubiquitous text editor as gets default, but I don't recommend that at all. In
fact, I'm going to switch mine to Visual Studio Code. That's going to be as Git's
Studio Code. That's going to be as Git's default editor. I believe if we go back
default editor. I believe if we go back to Vim really quick, I think it's up here. If we go back to Vim, I think it
here. If we go back to Vim, I think it says, uh, note Vim is a default editor for historical reasons and is highly recommended to switch to a modern GUI
editor instead. Uh, I concur. Vim is uh
editor instead. Uh, I concur. Vim is uh great but is also very old. Um and it's kind of a ancient tool if you want to call it that. But I'm going to change mine to Visual Studio Code because
that's what I use when I am coding. So
we are going to use that. Let's go ahead and click on next. Now we need to adjust the name of the initial branch of the new repository. Now by default it's
new repository. Now by default it's going to call it master but that does potentially cause issues actually when you connect it with GitHub. And in fact
I prefer it being called main. That's my
personal preference. But we're going to keep it as master because I will show you how you can just change the branch name once you get in there. But if I were doing this for myself, which I do
use it myself, then I would just call it main. But let's keep it as let get
main. But let's keep it as let get decide and we'll click next. After this,
we have to adjust our path environment.
Now there are some different options and they can be a bit limiting depending on what you want to choose for your path. I
recommend just using the get from the command line and also from thirdparty software. That'll help us down the line
software. That'll help us down the line just for simplicity purposes. So, I'm
going to keep it that and click next.
Next, we have to choose our secure shell client program. Which one would you like
client program. Which one would you like to use? And we're of course just going
to use? And we're of course just going to use the bundled open SSH. If you want to use an external one and you know how to do it, then you can do that. But if
not, just keep it with the default option. Next, we have to choose our
option. Next, we have to choose our HTTPS transport backend. If you have an open SSL library, you just need to kind of verify this and you'll need to make sure that that's set up properly. We're
just going to use our native Windows secure channel library that's already built in. Next, we have to configure the
built in. Next, we have to configure the line ending conversions. We're going to check out the Windows style. I'm going
to keep it for Windows because it just makes it easier and that's what I'm used to. Now, we have to configure the
to. Now, we have to configure the terminal emulator to use with Git Bash.
We're again keeping it as the default option here. Now, this one is quite
option here. Now, this one is quite important. It says choose the default
important. It says choose the default behavior of git pull. Now git pull is something that we will be looking at in this series. And when you write git pull
this series. And when you write git pull and you run it, what do you want it to do by default? Do you want to fast forward or merge rebase? Only ever fast forward. So there are different options
forward. So there are different options that we can have. Now by default it's fast forward and merge. So it says fast forward the current branch to the fetch branch when possible otherwise create a
merge commit. You can also choose rebase
merge commit. You can also choose rebase which which it will rebase the current branch onto the fetch branch. If there
are no local commits to rebase, this is equivalent of a fastforward or just use a fast forward. Now, you guys, if you've never used git, have no idea what this means, but I'll talk about some of this
once we get to it. But we're going to keep it as fast forward or merge. Next,
if you want, you can use a credential helper, and I do recommend that. So,
we're going to keep it. You don't have to. You can just choose none. Let's go
to. You can just choose none. Let's go
ahead and click next. It's asking us if we want to enable file system caching or enable symbolic links. You can do both or none. I'm just going to keep the
or none. I'm just going to keep the first one as default. And now we can install Git on our local machine.
It should be very very quick. Git is a very light program. And so this should be done in just a minute. All right. So
it is all done. It says completing the Git setup wizard. We can launch Git Bash or view the release notes. I don't need to view the release notes, but I do want to launch Git Bash. Let's go ahead and
click finish. And there we go. It's
click finish. And there we go. It's
going to go ahead and open up Git for us. So, this is Git Bash and now we do
us. So, this is Git Bash and now we do have this installed. Now, in the next lesson, what we're going to do is we're going to get in here. We're going to initialize a repo. We're going to have some files and see how we can save it
and create those snapshots like we talked about in the last lesson. But
right now, we have it installed. This
should be good to go. Now, let's come up here to GitHub. And what we're going to do is we are going to sign up for a free account. What we have to do is provide
account. What we have to do is provide an email, password, a username, and where you live. And we can create our free account. So, let's go ahead and do
free account. So, let's go ahead and do that. Now that I have that filled out, I
that. Now that I have that filled out, I called my username Alex the Analyst Git series because I already have a bunch of other GitHub accounts and so I can't just call it Alex the Analyst. But,
let's go ahead and create our account.
And now, we need to go to our email and type in the code that they gave us. Let
me go get that code. All right, I went ahead and put it in there. And now we have created our account. Now, we just need to sign in. So, if it's a Google account, you can sign in with Google. If
it was just an email or username, you can do that and put in your password.
I'm going to go ahead and sign in with my username and password. Let's go ahead and click sign in. And now we have a GitHub account. Congratulations. Let's
GitHub account. Congratulations. Let's
come right over here and let's go to our profile. So, in our profile, we can see
profile. So, in our profile, we can see how many commits we've made, which is basically none. I guess we have one.
basically none. I guess we have one.
It's saying we have a commit, but I didn't make any commits. And then we have no repositories. So, we are going to in the next several lessons, we're going to learn a lot about Git. We're
going to learn how to connect Git to GitHub and learn how to collaborate between the two very much like you would in a real job. 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
screen here. First, I have Git Bash open. Go ahead and pull that up on your
open. Go ahead and pull that up on your screen. You should just be able to
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
lesson. So you should have that installed. Just pull up git bash and it
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
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,
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
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
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
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
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
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
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
alphabetical order. We're going to say aa get video series. And so, let's go ahead. Well, we can either refresh right
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 Git video series right here. Let's open this up. And this is beautiful. There's
up. And this is beautiful. There's
nothing inside of it. This is just it's lovely, right? But we don't have access
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
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,
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
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,
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
files. We're going to add and commit them. And then we'll see how we can look
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
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
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
just yet. And then if we come right here, you can see that now it is connected. So now we have this master
connected. So now we have this master branch right down here connected to this AA get video series. That's because in our folder we have a git repository
initiated. So when we connected to that
initiated. So when we connected to that file path within our explorer it picked up the fact that we are connected to get 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
file. So we're just going to come up here. You can either say control alt
here. You can either say control 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
python file. Let's keep it really simple. So I'm just going to add a
simple. So I'm just going to add a comment here. I'll say this is a new
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 and we can save it right in here. And I'm going to rename this.
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
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.
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
file. It shows that we have a file in it. But if we go and we write get status
it. But if we go and we write get status right here, we're going to get some information. The status basically tells
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
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
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
unttracked file. So here's what we need to do. We have to do two things. I
to do. We have to do two things. I
pulled this up just so we can kind of see it. But right here we have to do two
see it. But right here we have to do two things. We're in our working directory.
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
local repository. That's our git repository which we can then use to take those snapshots. So let's first use git
those snapshots. So let's first use git 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
specify that. I don't almost ever do that. I usually just hit period, which
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've made changes to this file. So, we're going to hit get add
file. So, we're going to hit get add everything. And now let's go and hit get
everything. And now let's go and hit get status again. And now you can see we
status again. And now you can see we have a new file. These are changes to be committed. We haven't committed it just
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
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 dashm, 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.
message. Let's go ahead and commit this.
And says master root commit. This is my first commit. Woohoo. One file changed
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
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
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,
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.
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 say I love git.
simple code. I'm going say I love git.
There we go. Um, and then we're going to save this. Crl S. So now we've saved
save this. Crl S. So now we've saved this file. And now we have a new letter
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
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
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
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.
writing. And we're going to save that.
And I'm just going to call this one 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
file py. Now we have it in two separate sections. One is just the changes have
sections. One is just the changes have been made. The other is this one has
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
this. We're going to make another commit. So let's commit this. And it
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
the moment. Let's go ahead and commit this. And you'll see right down here, we
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,
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
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
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
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. Hello everybody. In
this lesson, I'm going to show you how you can revert back to a previous commit. Now, if you haven't been
commit. Now, if you haven't been following along, this is about the third video in this git series, and up until now, we have created a few separate commits over here. One with a small spelling issue. That's no problem in the
spelling issue. That's no problem in the commit message. Now, what we've done so
commit message. Now, what we've done so far is we've created our working directory. We used git init. And then we
directory. We used git init. And then we added these to the staging area. We
committed them to a local repository.
But what we now want to do is come right down here and go back in time. We want
to use get checkout. And we want to actually check out a previous commit and put that into this working directory.
And so let's see how we can do this. So
we have these previous commits and this is our first commit and this is when we first created this file and if we come right up here we only have this comment
in our code and we added this in our second commit. And so let's pull up this
second commit. And so let's pull up this right here and of course our git bash.
Now, what we can do is we can just use get checkout to go into something called a detached head state where we're just looking at our previous commit or where
we were in that snapshot. We're just
looking at it. So, let's say get checkout and then what we're going to do is we're going to copy this entire hash.
And so, I'm going to do this. Now, in
order to copy this in here, and I'm on a Windows machine, I'm going do control insert. And then if I bring it right
insert. And then if I bring it right down here, I need to do shift insert.
I'm going to hit enter. And now we're going to get this message. And it's
going to give us some good information.
And let's just see what it says. It says
you are in a detached head state. You
can look around, make experimental changes, and commit them. And you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want
to create a new branch to retain commits you create, you may do so now or later using - C with the switch command and then they give a little example or undo with get switch. Now this is just
advice. You can turn this off. Now what
advice. You can turn this off. Now what
we're able to do is we can say ls and this is our directory. Now we are taking a snapshot of this one right here. We're
going back and we're checking it out.
And remember we had two files in here previously and now we only have one. So,
it is showing us in our file path as well as in git that there's only one file in there. And if we go into our Visual Studio Code, this file isn't even exist anymore. It's gone. And if we go
exist anymore. It's gone. And if we go to our first file, that code that was previously down here is not there anymore. So, this one is deleted because
anymore. So, this one is deleted because it's not in that current git path. And
this one is reverted back to the code that we had only at the point or the snapshot of when we made that first commit. And so this is a very important
commit. And so this is a very important concept to understand when you're using git is we are looking at this snapshot.
Now we looked around and you know we don't need to go back and change anything for that specific one. We
actually want to go back to this one. We
can do that but I'm going to show you a little bit more than that. What we can do is we can say get checkout and then we have our master branch. And I'm just going to say master in here. Let's go
ahead and hit enter. And we've now come to our most recent commit in this branch. Now this is our master branch.
branch. Now this is our master branch.
This is our main branch. I call it main and master because uh GitHub calls it something different. Git kind of had
something different. Git kind of had that default of master. Um but ours was called master. And so we used uh right
called master. And so we used uh right here git checkout master to come back to our most previous one. And so now if we look at our ls now we have both of those files. This code is back to how it was.
files. This code is back to how it was.
This code is now there. And so
everything in the world is right.
But let's say we want to go back and we want to make some changes. I don't
recommend just going back and checking it out and making the changes right there. I actually recommend creating a
there. I actually recommend creating a new branch. Now let's say uh let's
new branch. Now let's say uh let's actually come down here. We'll do get log. Let's say we want to come back to
log. Let's say we want to come back to uh this second commit right here. So we
had just updated this first file. We
hadn't even added this text file in, but it had that code in there. Let's say we want to go back and we want to change some things, but we still want to keep some of this other information with this latest file. So, let's say we want to
latest file. So, let's say we want to come back and we actually want to start at this right here. So, this is our second commit. We just updated this
second commit. We just updated this first file with this code. That's all we added. This was our code from our second
added. This was our code from our second commit, but we want to add a little bit more, but we want to also save what we're currently working on. We're going
to do something called a creating a separate branch. And a branch looks
separate branch. And a branch looks something like this. We have our master and that's what we're working on right now. But you can create this branch
now. But you can create this branch where you can work parallel to your master branch and then you can merge it back to your main work at the same time.
This is great for collaboration because someone else can also create a separate branch, work on that work, and they can merge it back. Now, in this lesson, I'm just going to show you how to create the branch and you can do work there. But in
the next lesson, I'll show you how to create a branch, do some work over here, and then how you can merge it back into the master branch because that is how an actual workflow when you're using Git or
GitHub, that's an actual workflow within it. So, I want to show you how to do
it. So, I want to show you how to do that in the next lesson. So, let's come in here. We're going to do get checkout,
in here. We're going to do get checkout, but instead of specifying here's where we want to go, I'm going to first say dashb. So I'm creating a branch from
dashb. So I'm creating a branch from this location. But we need to name it
this location. But we need to name it really quickly. So I'm going to call
really quickly. So I'm going to call this branch for work. So that is the name of our branch. And now we need to
specify and whoops. See I accidentally uh tried to use C. Let's try this again.
We'll do sorry get checkout B. We'll
call branch for work. I need to come up here and use controlinsert.
And then I need to say shift insert. So
now we're saying get checkout. So I'm
checking this out. I'm creating the branch and naming it. And this is the one we're checking out. Let's go ahead and hit enter. And now you see something a little bit different. We've switched
to a new branch that we just created.
And then right over here instead of master it says branch for work. So this
is our current branch that we are on. So
now we can add files. We can come in here and change things and if we want to then we can merge it back to our main branch with all this new work that we've done. So in the next lesson we're going
done. So in the next lesson we're going to see how we can add files to this branch and then merge them back into the main branch. Hello everybody. In this
main branch. Hello everybody. In this
lesson we're going to be taking a look at branching and merging. Now in the last lesson I already created a new branch. I'm going to kind of walk
branch. I'm going to kind of walk through because this may be the first one you're watching. Okay, I'm going to walk through how to create that new branch and we'll walk through a little bit about how it works and how to merge it back into this master branch. So,
what we've done is we were here on this master branch and we just said get checkout and we checked out a previous version, a previous commit using this hash right here and we named it branch
for work. So now we're on the separate
for work. So now we're on the separate branch. We just were on our master and
branch. We just were on our master and we made this branch upward and now we are right here. So just for demonstration purposes, let's go back to
our get checkout master. So we're
actually going back to the master branch. We have created this branch for
branch. We have created this branch for work. And so if we want to get to that,
work. And so if we want to get to that, we can go and go back to this branch or we can create a whole new branch. Either
one is perfectly fine. I'm going to show you how to create another branch and then go back to this branch for work in just a second. So let's create this other branch, just a brand new branch.
So to create a new branch from our master branch, it's going to be really easy. We're going to say get checkout-b.
easy. We're going to say get checkout-b.
And then we name it. We'll just call it new branch.
And then we're taking that from master.
So our current work. Let's go ahead and hit enter. And now we're on this new
hit enter. And now we're on this new branch. Now this is with our current
branch. Now this is with our current files. But what we were doing with our
files. But what we were doing with our branch for work is we opened up a previous commit instead of our master.
So instead of master, we opened up using this hash right here. So let's actually switch over back to that previous branch that we created called branch for work.
So to switch back, it's really easy. We
again say get checkout and then we'll say branch for work. Let's go ahead and hit enter. And now we're on our branch.
hit enter. And now we're on our branch.
Now this previous branch does not have all of our commits. So, this file was not in that previous commit that we're looking at, that second commit. And
that's what we're going to do. We're
going to add some files. And then we're going to see how we can merge this back into our master branch. So, let's come right over here. Let's go on up. We only
have this first file. So, we're going to make some changes. We're going to say, uh, this is a change to our code.
And I'm going to print out I love merging and branching. Nobody
actually says that, but we're going to say it. And I'm going to save that. And
say it. And I'm going to save that. And
then we'll also add a file. If you
watched our previous lesson on Visual Studio Code, this is means it was modified. So we're going to add a new
modified. So we're going to add a new file now. And we're going to call this
file now. And we're going to call this one branched file.txt.
file.txt.
So this is just a text file. So I'm just going to say this is a text file for the new branch. And that's all we're going
new branch. And that's all we're going to do. We're going to save this. So I
to do. We're going to save this. So I
did control S. And so now we've made a modification to a previous file. And
we've added a new branched file.txt completely separate. So here's what
completely separate. So here's what we're going to do. We're going to go back and this is our current file path.
So, we have that branched file and then we also have a modification to the first file. Here's what we need to do to merge
file. Here's what we need to do to merge this back into our master branch because now we've added this new file. We've
made some changes to code. This looks
great, but we need to get it back to our master branch so that other people can see it. We can put it into GitHub. We
see it. We can put it into GitHub. We
can share that with our team. So, here's
what we're going to do. We're going to go back to our master branch. We're
going to say get checkout master. So now
we're in our master branch. And if we say ls, you'll notice that that file is there. But if we do get status, you'll
there. But if we do get status, you'll see that we have a modified and we have this file right here. So we haven't
committed or made these changes yet. All
we need to do is we can say get merge branch for work. So it looks like when we switch back to this master branch, it already made the merge. In fact, let's check this. We'll say get log. As you
check this. We'll say get log. As you
can see right here, we have our first commit, we have our second commit, and then for a third commit, we have head to master, but then we also have this new branch. And so it merged it back to the
branch. And so it merged it back to the main branch when we went and checked it out, but it still hasn't committed and saved this to the GitHub repo. So we
still need to get add. Actually, let's
do uh get status first. So we still need to say get add dot. Then it's going to add everything. And then we need to say
add everything. And then we need to say get status again just to check it. And
now the modified and the new file are there. And now we need to commit this.
there. And now we need to commit this.
So we're going to say get commit dash m.
And here's our message. We're going to say committing files after merge. And so now these files were
after merge. And so now these files were added and they were updated and modified in the main branch. So all that work that we were doing in this other branch
is now in our master branch. And if we come back here, it should have that updated and it will note that we have added these files and made those
changes. So that's how we create these
changes. So that's how we create these other branches and then we bring them back and put them in our main branch.
Now what's really important once we do have this master branch or even if we have these other branches is that we put this to where other people can see it.
that's in our GitHub. So, in the next lesson, we're going to connect our Git with our GitHub. So, that's our local repository with our remote repository so that we can sync these up and use them in parallel. Hello everybody. In this
in parallel. Hello everybody. In this
lesson, I'm going to show you how to connect your local Git repository to your online Git remote repository. So,
we've been working for the past several lessons. We've created a repository and
lessons. We've created a repository and now we want to connect this to GitHub so that we can remotely store and have all of our commits on GitHub, not just on
our local machine. So in here we created our GitHub. But now what we need to do
our GitHub. But now what we need to do is we need to come in here and create a repository. So we're going to select a
repository. So we're going to select a new repository. I'm going to call this
new repository. I'm going to call this the Git series repo. And I'm going create uh this as a public repository.
So anybody can go and take a look at this. And we're not going to change
this. And we're not going to change anything else. Just keep it super duper
anything else. Just keep it super duper simple. Let's go ahead and create this
simple. Let's go ahead and create this repository. And it's going to be
repository. And it's going to be completely blank. Nothing is in here.
completely blank. Nothing is in here.
There's no files. There's nothing. And
what's great is that GitHub knows, they are very good. They know that you want to connect this to your Git repository.
And so they give us instructions on how to do that. So if you want to create a new repository on the command line, you can or push an existing one. Now that's
what we want to do. So we can copy.
Well, I'm going to copy this. We're
going to add a remote origin. And origin
is just the name, but let's look at this in a second. Let's come over here. I'm
going to do shift insert. So get remote ad. We're adding a remote repository.
ad. We're adding a remote repository.
And we're calling it origin. That's kind
of like a default name. We don't have to call it that. Um, but it's just common for people to do that. And then here is the link to this repo remote repository.
And that's it. Let's go ahead and hit enter. And so now we have connected this
enter. And so now we have connected this local Git repository to this remote repository in GitHub. So now what we're going to do is come over here and we're
going to click on publish branch. This
is going to allow us to sign in with GitHub. So, we're going to sign in with
GitHub. So, we're going to sign in with your browser.
Then, we're going to authorize the Git ecosystem. So, we're going to say
ecosystem. So, we're going to say authorize. Now, we're going to come back
authorize. Now, we're going to come back here and we're going to bring up our VS Code again. And it looks like we've
Code again. And it looks like we've already put it into the GitHub repo. And
you can see it right here. You can see that you can open it on GitHub, but it also has this uh little emblem that says that origin main is now in GitHub. So,
let's go back to our GitHub.
Let's click refresh.
And now we can see all of our files in here. So now we've connected our local
here. So now we've connected our local Git repository to our GitHub remote repository and now they are synced up.
Hello everybody. In this lesson, we're going to be taking a look at GitHub. And
then what we're going to be doing is seeing a little bit of a workflow of using both Git and GitHub together. If
you remember from our last lesson, we connected Git to GitHub. Now we can work on a little bit of that workflow of how it would actually look using both of these tools at the same time. We also
pushed all of our stuff from our local repo in Git into this GitHub repo right here. The first thing that we're going
here. The first thing that we're going to look at is we can actually take a look at our previous commits. So these
are all the commits that we made on our local repo, but when we connected it and we pushed it up into GitHub, we still have all of those commits here that we can see. And so that's really great to
can see. And so that's really great to see. We can also go in and this is our
see. We can also go in and this is our first file. py. We can click on this
first file. py. We can click on this file and we can actually look at the code that is in here as well as of course our other files as well. The next
thing we're going to take a look at is a pull request. Now, we're going to be
pull request. Now, we're going to be looking at a pull request in just a little bit. We're going to see how that
little bit. We're going to see how that works. But a pull request is something
works. But a pull request is something that is different between GitHub and Git. On Git, you can just commit and
Git. On Git, you can just commit and merge and do all those things basically whenever you want. But within GitHub, we do have to create a pull request, which
is how you approve code, and you get things merged back into the main branch.
We will be taking a look at that in just a little bit. There also is issues, and issues are really common, especially within larger teams. So if you're working on code, you can create a new
issue and you can assign it to somebody, you can label it, you can assign it to a project or whatever milestone you might be working on and you can create it. And
so you know if you're going back in the code and you see, oh, there's something wrong with this first file in our output on our website or for this customer, they're getting something weird. So we
create an issue, we assign it to someone, and then it will show up right in here. So let's go ahead and create a
in here. So let's go ahead and create a new issue really quick. I'm just gonna assign it to myself and I'm gonna say uh first file not working correctly. This
is a terrible uh title, but then in here uh this is the details you need to know.
So then I would write up, you know, here's what's going on. Maybe I need to attach a file or something. Uh but here you need to know. And I'm going to
create this. And so now if I come back
create this. And so now if I come back to issues, we can see that this is assigned and I can make sure I can see the ones that are assigned to me and
I'll come in here and then I'll say I fixed this and I can just say close with comment. So now it's going to be closed
comment. So now it's going to be closed out. I fixed this issue and now it is
out. I fixed this issue and now it is closed. And so that's how you assign and
closed. And so that's how you assign and you can get things assigned to you from your team. If I hop over here to
your team. If I hop over here to projects, projects is a little bit there. There's a lot of things that you can do in projects. Uh
let's get rid of this. But a lot of teams will use this almost like a Jira board or a can conbon or cananban board, however you say it. Um but you can create these different projects and you
can assign different things to people.
Let's just create a board here and it's just a blank one, but this is like a board that you use it with any other project. has to-do and progress done.
project. has to-do and progress done.
And this is where a project manager or somebody on your team might come in and organize this. They might have things
organize this. They might have things set up that you need to accomplish that your team needs to accomplish. So, this
can be really useful. If I'm being honest though, my team almost never use this. We always use something like Jira
this. We always use something like Jira or something that Microsoft had Microsoft shop. And so, I didn't use it
Microsoft shop. And so, I didn't use it that much if I'm being honest, but you can use it. Uh, let's go back into our git series. The last thing I want to
git series. The last thing I want to show you is we can create other branches in here. So right now we only have the
in here. So right now we only have the main branch. That's all we pushed. But
main branch. That's all we pushed. But
we can create multiple different branches in here. And when we create these separate branches, we can then make changes on these branches and merge it back into our main branch. So let's
go up here. Let's click on this branch.
And we have our main branch. And let's
go ahead and let's just create a new branch. Let's get let's get wild. We're
branch. Let's get let's get wild. We're
going to say new GitHub branch and we're going to create this new branch. So now if we go back, we're
new branch. So now if we go back, we're going to go to our code. If we go back to main, we now have our main, that's our default branch. We have this new GitHub branch. Let's go ahead and click
GitHub branch. Let's go ahead and click on this. This is basically a copy of our
on this. This is basically a copy of our main branch. And so it has all the same
main branch. And so it has all the same commits. It has all the same files and
commits. It has all the same files and information in here. But let's go ahead and let's add a file. We're just going to create a new file. And we're going to come in here. We're going to name this
file. So I'm going to call this a GitHub
file. So I'm going to call this a GitHub file. py. And we're going to say this is
file. py. And we're going to say this is a file just for GitHub. And we're going to commit these changes and go ahead and commit them. And now
we're getting this message that says this branch is one commit ahead of main because we just went into this new branch and we added a new file and we committed it. Now if we go back to the
committed it. Now if we go back to the main branch, you're going to notice we no longer have that new file that we created. It's just in that separate
created. It's just in that separate branch. But now we're going to get this
branch. But now we're going to get this message up here. It says new GitHub branch had recent pushes 15 seconds ago.
It's going to want us to compare and create a pull request. Let's go ahead and click on this. So if we do this, we're going over basically to opening a pull request. What this does is it
pull request. What this does is it creates a new pull request by comparing changes across two branches. And if you need to, you can compare them across forks as well. So we can create this
pull request. So let's go ahead and
pull request. So let's go ahead and create pull request and it's going to see if there is a conflict with the branch. Now, conflicts
within a branch means that a file was changed in both the main branch and it was changed in a different branch. And
if you tried to merge them, you're going to get a conflict because you changed both of them. Of course, we didn't do that. So now we can merge this poll
that. So now we can merge this poll request. Let's go ahead and merge this
request. Let's go ahead and merge this back into the main branch. We're going
to confirm this merge. And now you can see that this was appropriately merged.
Let's go back to our code. And now in our main branch, you're going to see that that GitHub file was added. And so
now both of these branches are up to date. The only thing that is not up to
date. The only thing that is not up to date is if we come back here. Because if
we come back to our local repository, this is not updated. And so let's see how we can pull that new file that we created in GitHub and we're going to pull that down to our local repository.
And just by clicking refresh, it says that we've synchronized those changes.
But let's come back to our source control. You can see right over here, we
control. You can see right over here, we committed these files, but then you see this little orange line right here. It
says that we created a GitHub file. Then
we merged that pull request within GitHub. And now main and origin main,
GitHub. And now main and origin main, which is GitHub, are both on the most recent commit. Now what you may also
recent commit. Now what you may also want to do is you may also want to come in here and say get pole origin main and that is also how you can pull that down
just using git natively. Of course we are already up to date so we don't need to do that. But let's go add one more file and let's just test that out. So
we're going to come in here. We're going
to add another file. We're gonna call this uh GitHub file 2 and just say this is the second file.
And we're gonna go ahead and commit these changes. And this should be on our
these changes. And this should be on our main branch. So we should be perfectly
main branch. So we should be perfectly fine. So there we go. Now we're going to
fine. So there we go. Now we're going to write the same thing. So this is on our local repo. We're going to say get pull
local repo. We're going to say get pull origin main. And then it's going to say,
origin main. And then it's going to say, okay, let's bring down everything that we don't already have. Any changes, any new files. If it's new and it doesn't
new files. If it's new and it doesn't sync up to our last commit. Let's take a look at that. So, we have this one file changed. That's our GitHub file 2. Let's
changed. That's our GitHub file 2. Let's
go ahead and say ls to take a look. And
now you can see that we have that GitHub file 2 right here. We didn't call it py.
Uh we probably should have. In fact, we could come in here and change that if we want to, but we don't need to. But let's
go back. Now we have git. Uh let's open up VS Code and Git. Um if that file is showing right here, we should also see it right here. So we open that GitHub
file too. And this is the second file.
file too. And this is the second file.
And so that's how we can pull down files or changes from GitHub. And typically
that happens when someone on your team uploads a new file or a client uploads a new file and you want that file locally so you can actually do your work. And so
you'll pull that down. So then it's in your local file folder and you can actually use that file. And the same thing would apply. Let's say in here we need a new file. We're going to create a
new file. Let's say it's a Python file.
new file. Let's say it's a Python file.
We're just going to say this is the latest file with our code. And we're
going to go ahead and save this. And
let's call this get file one. And let's
save that. So now we have a file that is unttracked. It hasn't been put into any
unttracked. It hasn't been put into any repository, local or remote. We can come over here and we can first add this. So,
we're adding it to our staging area. And
now we can commit this. I didn't add a message. Let me actually get rid of
message. Let me actually get rid of this. Let's add a message. We're going
this. Let's add a message. We're going
to say get local repo. Whoops. Let's do
get local repo change. And we're going to create that commit. But now these are out of sync, right? So now we have our GitHub repo that's back here. So we have
it a file behind and then we have our local repo and we just did a bunch of work. We worked really hard on this git
work. We worked really hard on this git file one and we want to push that so that it's in the GitHub. It's sharable.
We can access and so can the people on our team. So we're just going to click
our team. So we're just going to click sync changes and it's going to sync up to where that file is now in GitHub and they are both on the same place. So now
let's go back and if we click refresh right here, we should see that git file one as well. And that's a really common workflow. Of course, like we said in the
workflow. Of course, like we said in the last lesson, you may want to create a branch off of that and do your work and then merge it back into the main branch so you aren't messing with the current files and you don't mess anything up. Of
course, you can always revert back or check out a previous commit. And that is really the power of Git in a nutshell.
and then you can share it to your GitHub so that people on your team or you can have access to it anywhere or have access to it later. So, I hope that that was helpful. I hope that you learned
was helpful. I hope that you learned something in this series. If you want to dive even further into Git and GitHub, I have a full course on my platform analystbuilder.com. I will leave a link
analystbuilder.com. I will leave a link in the description if you want to check it out. If you have not already, be sure
it out. If you have not already, be sure to like and subscribe and I will see you in the next video.
[Music]
Loading video analysis...