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