Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
An overview of how the Git version control system works.
Video Review
- Git is a version control system. It helps you control the different versions of the files in your project.
- The collection of all the old versions of your project's files is known as a Git repository. It's basically just a folder in which you can edit your files, then run Git commands to store your changes.
- Each time you complete a change to some or all of your project's files, you can take a snapshot of their current contents. These snapshots are known as commits.
- Git is a distributed version control system, as opposed to a centralized system. In a distributed system, you can copy a complete repository with the full project history to every developer's machine.
- Bash is a command shell that runs on many Mac, Linux, and even some Windows computers when you open their terminals.
- Bash prompts usually end in a dollar sign. When you read Git tutorials out on the web, you may see a dollar sign; that usually indicates that the text following it should be typed at a shell prompt.
- When Git is installed on a system, like it is here in this workspace, it places an executable named
git
where it can be run from any shell prompt. This is thegit
command. - All the commands we're going to show you during this course will use this executable, so they're all going to start with
git
followed by a space. - Then we need to specify the subcommand or options we want.
- Git command line options consist of either a single dash followed by a single letter, or a double-dash [type
--
] followed by a word. -
git --help
will print out some help on using the Git program.
Common Git subcommands
- The
git clone
andgit init
commands are used to setup new repositories. - The
git add
,git status
, andgit commit
commands are the most frequently used subcommands in all of Git. They're used when committing new versions of files. - The
git log
command is also important; it lets you view a list of your old commits. - The
git mv
andgit rm
commands move and remove files that are being tracked by Git. We'll learn about those in Stage 2 of this course. - The
git push
andgit pull
commands are used to synchronize commits with Git repositories on other computers. We'll learn about those in Stage 3.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
We've told you that Git can
keep you from losing work and
0:00
that it can help teams
work together on projects.
0:03
But how exactly does it do that?
0:06
Git is a version control system.
0:08
It helps you control the different
versions of the files in your project.
0:10
It keeps track of all the changes
to your files over time.
0:14
If you ask it to, it can reset any files
contents to match a previous version.
0:18
Or, more commonly,
0:23
you can reset the version of all
the project files at the same time.
0:24
The collection of all the old
versions of your projects files
0:28
is known as a Git repository.
0:31
It's basically a folder in
which you can edit your files
0:33
then run Git commands
to store your changes.
0:37
You can have multiple Git repositories
on your computer, one for
0:40
each project you're working on.
0:43
So at this point you may be
thinking Git is just like
0:45
network backup software like Dropbox or
Google Drive, right?
0:48
After all,
0:52
those programs store a new version of
a file every time you save it too.
0:53
But Git is way more powerful
than just making backups.
0:57
For one thing, it's intended to help
developers work together on a project.
1:00
With just a couple commands, you can clone
an entire repository to another computer.
1:05
This clone will include the full
version history of all the files.
1:11
Once they have the files
on their own machine,
1:15
other people can make their own changes.
1:17
And Git includes commands that
let you easily bring changes from
1:19
other people's repositories
back into your repository.
1:23
Each time you complete a change to some or
all of your project's files,
1:26
you can take a snapshot of
their current contents.
1:30
This snapshot represents a point in your
project's history that you might want to
1:33
travel back to some time in the future.
1:37
These snapshots are known as commits.
1:39
Just as you might take a phone number and
commit it to memory so
1:42
you can remember it later, you can commit
a version of your projects files to
1:46
your Git repository, so
you can get that version back later.
1:50
But most version control
programs have features like this.
1:54
Why is Git in particular so popular?
1:57
There is a variety of reasons for
this, but here's an important one.
2:00
Git is a distributed version control
system as opposed to a centralized system.
2:03
In a centralized system, the repository
with all the old versions of files lives
2:08
in only one place, a central server.
2:13
If anything happens to
that central repo and
2:16
you don't have current backups,
all the old versions will be lost.
2:19
In a distributed system,
you can copy a complete repository
2:23
with the full project history
to every developer's machine.
2:26
Commands are available to synchronize
repos with each other as new
2:30
changes are made.
2:33
If anything happens to one of those repos,
2:35
the data in any other repo
can be used to restore it.
2:37
Let’s open up a workspace and
try our first Git command.
2:41
It’s not going to look like much, but
2:44
Git’s plain looking command line
interface hides some major power.
2:46
You’ll see what we mean over
the rest of the course.
2:50
If you’re watching this
video on the Treehouse site,
2:52
there should be a Launch Workspace
button on the page, so click that.
2:55
You'll see a dialog where you can
rename your workspace if you want.
2:59
Click the Launch it
button when you're ready.
3:02
A new window will open with
a Treehouse workspace.
3:05
Give it a minute to load.
3:08
You'll see the sidebar with the list
of files in this workspace, and
3:10
a text editor, but we're not going
to use those much in this course.
3:13
What we want is the console
panel down here at the bottom.
3:17
Let's resize that so we have more room.
3:21
Next, we need to activate the console.
3:25
Click anywhere within the console panel.
3:27
You'll know it's been activated if
a blinking cursor appears down there.
3:29
This is a prompt for Bash,
a command shell that runs on many Mac,
3:33
Linux, and even some Windows computers
when you open their terminals.
3:37
This particular prompt shows
the current username and
3:41
then the name of the directory or
folder that we're currently in.
3:43
It's a directory named workspace,
in this case.
3:46
Bash prompts usually end in a dollar sign.
3:49
When you read Git tutorials out on
the web, you may see a dollar sign.
3:52
That usually indicates that the text
following it should be typed at
3:55
a shell prompt.
3:59
Note that when following along with
a tutorial, you should not actually type
4:00
the dollar sign unless it appears
somewhere in the middle of the command.
4:04
Now we need to run Git.
4:07
Git is installed on a system,
like it is here in this workspcae.
4:09
It places an executable named git where
it should be run from any shell prompt.
4:12
This is the git command.
4:17
All the commands we're going to show
you during this course will use this
4:19
executable.
4:22
So they're all going to start
with git followed by a space.
4:23
Then we need to specify the sub-command or
options we want.
4:26
For this first command,
we're not going to run any sub-commands.
4:29
We're just going to git help
on the git command itself.
4:32
We do this with a command line option.
4:35
Git options consist of either a single
dash followed by a single letter, or
4:38
a double dash followed by a word.
4:42
In this case, we want the help option.
4:45
Once you've typed all that, your
command is complete, so press Enter or
4:48
Return to run it.
4:51
git --help will print out some
help on using the git program.
4:53
By the way,
4:57
it's okay if the output you see doesn't
exactly match what's shown here.
4:57
It just means you're running
a different version of Git than I am.
5:01
All the commands we show in this
course will work the same way
5:04
no matter what version of Git you have.
5:07
The only part of this output that's
really useful to us right now
5:09
is this list of subcommands.
5:12
These are used to invoke most
of Git's basic functionality.
5:14
And we'll be trying out many
of them during this course.
5:17
The git clone and git init commands
are used to set up new repositories.
5:20
The git add, git status, and
5:24
git commit commands are the most
frequently used subcommands in all of Git.
5:26
They're used when committing
new versions of files.
5:30
The git log command is also important.
5:33
It lets you view a list
of your old commands.
5:35
The git move and
git remove commands move and
5:38
remove files that
are being tracked by Git.
5:41
We'll learn about those in
stage two of this course.
5:43
And the git push and git pull commands
are used to synchronize commits with Git
5:46
repositories on other computers.
5:50
We'll learn about those in stage three.
5:52
That's an overview of
the most basic Git commands.
5:54
Up next, we 'll show you how
to create a Git repository.
5:57
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up