And yes, welcome to this demonstration and your real learning environment,
and we do so much encourage you to get your hands dirty
playing around on your demonstration system.
We're going to go through and create our own local Git repository.
So that's going to require us to have a new project directory.
We'll create in the root of our home directory.
We're going to initialize the repository,
and we're going to go through and add a new file and
commit changes back into that repository.
So come on, let's find that command line.
Now the first thing that we're going to do,
we don't want to create a Git repository inside a Git repository, so
move out of any existing repository that you're in.
I'm going to go through then and create a new directory.
I'm just going to call it, let's say, project1. Doesn't really matter.
We can move into that directory. Don't forget about escape and dot,
really nice feature that brings up our last argument.
Now, of course, even if I do an ls ‑a, I've only got the . and .. directories.
I don't have anything else in this directory at the moment.
But look what happens when I go through and run git init.
We're going to create a new repository, and that then goes through and
creates the .git subdirectory. It's that directory structure that stores
all of the information about my repository. Again, I can go through and
look at the git status command.
The git status command is going to go and show me, well,
okay, we're on the branch master. Here we're using master by default.
We've got no commits, so we don't have to worry about anything.
But the git status command is really useful.
It really tells me what I need to do.
If we go through and look at the git config command again and ‑‑list,
we can see then that I don't have a lot of information coming
through because I don't have any remote information about the
repository that we're synchronizing through.
I can create myself a new file.
So if I go through and echo "First text" or whatever, again,
it doesn't really matter, and send that through to my
file. Move that to the top just so you can see on the
screens just a little bit easier.
But now having done that, of course, we know what's going to be in that file.
But if I go back to my git and status command,
we can see now that I haven't saved anything, but we have an
untracked file, so we use git add to track that file. So I
can go through and go git add.
If I go dot, it just means the current directory,
but that will include everything below.
So if I go through then and add that, we automatically exclude the .git
directory, so we don't have to worry about that being added. And now go through
and take a look at the git status. We can see now that we've got a staging area,
and these are files that are ready to be saved.
If I don't want to save that file,
I can use a git rm ‑‑cached and then the file name.
Again, it gives me an idea of what to do.
But if I'm happy to make my change, I can go through and run the git commit,
specify the commit message, so ‑m, and then we can put First
commit or whatever message that we want.
Generally, the more useful information we can put there, then again
it makes sense when we look at the commits later.
So we've now made that change.
Remember, you have to have a user and email address
to be able to make those changes.
If I go through and look at git log, we can then start seeing
that the author Tux Penguin of this email address then made a
commit at this date and time.
Now we only have one commit, so there's only one commit to read, so
having it over multiple lines is not a problem.
But if we've got multiple commits, it's much easier to read the
information with git log ‑‑oneline. With this then, all of the
information is summarized for each commit on a single line.
So we still might have multiple commits and multiple lines,
but the details are on a single line.
So we get a shortened version of our ID, we can see our head is at
that commit, so this is our current working area,
and we get to see then our message, First commit.
Now that we know how to make our changes, w. We're going to look at how we can revert changes.