Git only adds files to your repository, and it's very
difficult to get the system to do anything you can't undo if you make a mistake.
Git allows you to compare the differences between various versions of your project.
Remember we said that in distributed version control systems,
you store snapshots of your project.
So you can store these and then merge them if you need to.
You can think of the various versions of the project as forming a tree.
There's the main development branch, and in Git this is called master.
And then you can create new versions either along the master branch or
you can branch off the master branch, you can creat new branches.
The branches can be merged back in if you decide you want to merge some
features together.
Let's go over some basic concepts associated with Git.
First again remember the git tracks files and
these files, they can be thought of as residing in one of three locations.
They can be in your Working directory, you can stage them to the Staging area or
you can store them in a Git repository.
Further, the files in the working directory can be in one of two states.
They can be tracked and in this case these are files that were saved
by the last commit to your repository or they could be the untruck.
These are files that are in your working directory that have not been saved.
Furthermore tracked files can be either modified, in other words you've changed
that file since it was last committed to the repository, it's unmodified,
it hasn't been changed since that time, or it's staged.
Let's talk more about this.
These are the 3 locations I've just mentioned where files can reside.
So in your working directory If you type git add.
then it moves those files to the staging area.
Then from the staging area, if you type git commit,
then these fields will be moved to your local git repository.
You can do both of these in one step by just typing git commit-a, and
it will do both of them.
Now, if you want to check out a branch from the local git repository,
you type git check out in the branch you like to check out and then remove those
files in the local git repository to your working directory and then copy them over.
There's also a merge command that allows you to merge Your current working
directory with the branch that's stored on the local Git Repository.
Here's how to use Git with the Rails application.
First of all, move to the root of your blog application.
So here I'm in the root of the blog application that we previously created.
And I'd like you to make sure you follow along because you're going to need to be
able to use git in order to submit your first programming assignment.
We like to put this application under source code control.
First you have to have git configured on your machine so to make sure you do,
type git and you should see a list of help commands that are available to you.
Let's pick this one out, git status.
It shows the working tree.
Now, when I do this, it says that we don't have a git repository yet,
so in order to do this, you issue the Git command called git init.
git init will now create a git repository, just actually stored in our file called
Dot git in your local directory.
Now rails automatically also creates a file called dot git ignore,
that's in the root of your project directory as well.
Now this file is simply a list of the files that git will not include
in the repository whenever you save to the local repository.
So if I take a look at that