Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
Go in-depth with some of GitHubs most essential features, which are the backbone of open source on GitHub.
Git Commands:
-
git init: initialize a git repository in your directory
-
git status: check the status of the repository
-
git add file_name: add one file
-
git add .: add all files
- git commit -m “commit message”: commit your files along with a message
-
git remote add origin https://github.com/username/reponame.git - the remote url to your GitHub repo
-
git push origin master: push your files up to github on the master branch
Tips:
-
0:00
[MUSIC]
-
0:04
In this stage, we'll go in depth with some of GitHub's most essential features,
-
0:09
issues using markdown, branching, and pull requests.
-
0:13
Used together, these features are the backbone of open source on GitHub.
-
0:17
And learning how to use them to add your projects to the site,
-
0:19
will be a great foundation to both showcase your work, and
-
0:22
start contributing to the open source community.
-
0:25
So, now that we've created a repository, let's open our terminal and
-
0:29
push up a project to GitHub.
-
0:31
Quick review.
-
0:32
When I say push, I'm talking about the Git push command where we'll push our
-
0:36
project on our local computer, up to a remote repository on GitHub.
-
0:40
Later, we'll talk about Git pull, where we'll go over pulling the latest changes
-
0:44
from a remote repository down to our local computer.
-
0:47
I want to push up the files from the Treehouse Python course I recently
-
0:51
finished, so I'm in my completed Python Basics work space.
-
0:55
You can follow along using a work space for a course you've already completed, or
-
0:59
if you have Git installed on your local computer,
-
1:01
you can use your computer's console.
-
1:04
First, let's take care of some Git configurations.
-
1:07
I'll check the Git version by typing git--version.
-
1:11
Great, it looks like we have Git installed, and we're on version 1.8.
-
1:14
That's perfect.
-
1:15
We can check to see if we have any configurations already set up,
-
1:18
by typing git config --list.
-
1:23
Nope.
-
1:24
Okay, so then we'll need to set up our name and email address, so
-
1:27
Git knows who we are.
-
1:29
The commands for this are git config --global user.name,
-
1:36
your name in quotes, and git config --global-.
-
1:46
User.email and your email address in quotes.
-
1:57
Make sure the email you use is the email associated with your GitHub account.
-
2:02
These commands are also linked in the teacher's notes.
-
2:04
If using your local computer, I've added some additional links for
-
2:07
helpful command line configuration, for maximum Git and GitHub effectiveness.
-
2:12
Now, typically the name of the local directory matches
-
2:14
the remote repository's name.
-
2:16
So, I'm gonna create a folder, Treehouse, and move my files into it.
-
2:19
I'll type mkdir Treehouse.
-
2:25
This creates the directory, Treehouse.
-
2:28
And I'll type mv, which stands for move, *.py,
-
2:33
which says everything with the .py extension move to this directory.
-
2:42
Now if I cd or change directory into the Treehouse folder, and
-
2:48
I ls list everything out, I can see my two files are now in that folder structure.
-
2:54
And if I'm using work spaces over here, I can just click and refresh.
-
3:01
I can see that the two files are also under the Treehouse folder structure
-
3:04
in work spaces.
-
3:06
Next, we'll want to initialize the Git repository, so we'll type git init.
-
3:12
Initialized empty Git repository.
-
3:15
Great.
-
3:15
And then we'll type, git status.
-
3:20
This lists out all the files in the directory.
-
3:23
Okay, let's read what it says.
-
3:24
On branch master, we're on the master branch, and
-
3:28
this is because master is the default branch to be on, so this is great.
-
3:32
Un-tracked files, use git add, to include what will be committed.
-
3:38
So, I can type git add and the file name, to add a single file.
-
3:42
However, if we have multiple files like we do, that can be a bit tedious.
-
3:46
Instead, I'll use the shortcut git add ., to add all the files in the directory.
-
3:54
Next we'll commit, git commit -m and
-
3:58
in quotes we'll type, initial commit.
-
4:03
This commits all of the files and the -m adds the message initial commit.
-
4:10
Two files changed, lumberjack and number_game.py.
-
4:14
Great.
-
4:15
Now, we'll add our remote repository from GitHub.
-
4:22
GitHub provides us a shortcut with these commands we need here.
-
4:26
We'll copy the first line, and back in the terminal.
-
4:33
We'll paste it in.
-
4:36
This creates a remote, or said differently,
-
4:38
a connection named origin, pointing to the GitHub repo.
-
4:42
Now we'll push up our project.
-
4:44
Type in git push origin master.
-
4:49
This sends your commits in your master branch to GitHub.
-
4:52
You'll need to type in your user name and password.
-
4:59
If you're using your local computer, you can use the link in the teachers notes,
-
5:03
to cache your password so you don't have to type it in every time.
-
5:06
Congratulations, your project is now on GitHub.
-
5:09
To check it out, we'll refresh the page and we can see all of our files.
-
5:13
And if we click in, we can see the code.
-
5:16
Okay, so to review,
-
5:18
here are the commands we use to get our local project hosted on GitHub.
-
5:23
Git init, git status, git add.
-
5:27
Git commit -m quote initial commit git push origin master.
-
5:34
If you are working by yourself and pushing up projects,
-
5:37
those last four commands will be the ones you use over and over again.
-
5:41
Memorize these, or write them down on a sticky note where you can see them.
-
5:45
Next up, we'll use issues to track tasks related to our project.
You need to sign up for Treehouse in order to download course files.
Sign up