Push to GitHub

4:36

We want to be able to collaborate on this project. We’re going to use a site called GitHub to share our project. This video walks through creating a GitHub account, pushing our project to it, and adding collaborators.


Teacher's Notes

Links

Notes

Create git repository:

git init

Push to GitHub:

git push origin master

Extra Credit

More Statuses

Now that you've created a Rails app and statuses, why not try modifying the layout of the statuses index page. Maybe spruce things up a bit using your knowledge of HTML and CSS.

Video Transcript

  • 0:00

    Since Jim and I are going to be working on this project together,

  • 0:03

    we need someway to collaborate on it.

  • 0:06

    For that, we're going to use a Web site called GitHub.

  • 0:09

    GitHub will allow us both to work on the same project together.

  • 0:14

    So let's set that up now.

  • 0:17

    Now that we've done all of this work of creating status updates,

  • 0:20

    let's go ahead and give it to Jim to work on.

  • 0:23

    So let's go back to our terminal,

  • 0:25

    hold the Control key again, and press the letter C.

  • 0:28

    That will stop our Rail server.

  • 0:30

    The way that we're going to collaborate is through something called Git,

  • 0:33

    and a Web site GitHub.

  • 0:36

    What we're going to do first is initialize a Git repository

  • 0:38

    inside of our Tree Book application.

  • 0:41

    So inside terminal after stopping the server,

  • 0:44

    type git and then the word init

  • 0:48

    and we'll get this message saying that an empty git repository

  • 0:52

    was initialized inside of our Tree Book folder.

  • 0:56

    Now that we have repository initialized,

  • 0:59

    we have to add our different files to it,

  • 1:03

    so type git add

  • 1:06

    and then a dot.

  • 1:08

    The dot signifies that it's our current directory

  • 1:11

    and all directories beneath it.

  • 1:13

    Now once we've added our files, we have to do something called commit them.

  • 1:18

    Committing our files basically freezes the project at this moment in time.

  • 1:22

    So type git commit

  • 1:27

    then a space, a dash, and the letter m.

  • 1:31

    That tells git that we're going to add a message.

  • 1:35

    So type the message in quotes,

  • 1:39

    and the message I'm going to add is,

  • 1:41

    Created a rails application

  • 1:44

    and added status updates.

  • 1:48

    Now we can see all of the different files

  • 1:51

    that git added if we scroll up.

  • 1:57

    Now that we have this repository set up,

  • 2:00

    we need to go push it somewhere.

  • 2:02

    We're going to push that repository to a site called GitHub.

  • 2:09

    So go to GitHub.com

  • 2:11

    and click Plans & Pricing and sign up.

  • 2:16

    And you can create a free account.

  • 2:18

    Type in a user name,

  • 2:21

    e-mail address,

  • 2:23

    and a secure password.

  • 2:29

    Then click Create Account.

  • 2:31

    Now you have some different options for setting up Git,

  • 2:34

    creating a repository, forking a repository, and being social.

  • 2:39

    We've already got Git set up locally.

  • 2:42

    What we need to do is create a repository.

  • 2:45

    We did already create a repository locally,

  • 2:47

    but we need to create one on our GitHub page, as well.

  • 2:50

    So click New Repository on the bottom right-hand of the window.

  • 2:56

    Our repository name is treebook.

  • 3:00

    Click Create Repository.

  • 3:02

    We've already set up git in the Rails Installer project.

  • 3:06

    What we are going to need to do is this part

  • 3:08

    right here.

  • 3:10

    You can double click this line to select it,

  • 3:13

    and then copy it.

  • 3:14

    Go back to your terminal and paste.

  • 3:17

    What this is saying is that now we have something called origin

  • 3:20

    as a remote in Git.

  • 3:22

    What this means is that when we push up to origin,

  • 3:25

    it's going to contain the same thing as what we have locally.

  • 3:29

    Now here's another line right here.

  • 3:32

    Git Push.

  • 3:33

    So let's push up to git hub.

  • 3:39

    Now it will ask for our user name

  • 3:43

    and our password.

  • 3:46

    And then we can see it was successful, because it pushed to a new branch

  • 3:49

    called treebook.

  • 3:50

    It pushed our local master branch up to a new remote branch called master.

  • 3:55

    Now we're done, so we can click Continue,

  • 3:58

    and all of the files that we had are now inside of this repository.

  • 4:05

    And my last commit message is right here.

  • 4:07

    Now I need to add Jim to this,

  • 4:10

    so I can click on the admin tab

  • 4:13

    and then the Collaborators button.

  • 4:15

    Now I'll click inside that box and start typing Jim's GitHub name.

  • 4:21

    And click the add button.

  • 4:23

    Now Jim has access to this code, as well,

  • 4:26

    and he can start working on it with us.

  • 4:29

    Now our project is all pushed up to GitHub,

  • 4:32

    and we've created a status update.

  • 4:34

    Great work!

Show full transcript

Workspace

You have to sign up for Treehouse in order to create workspaces.

Sign up

Downloads

You have to sign up for Treehouse in order to download course videos.

Sign up

Instructors

  • Jim Hoskins

    Jim is a full stack software developer at Treehouse. When he's not writing code, he's blogging, teaching, or speaking at conferences. On Twitter he is @jimrhoskins.

  • Jason Seifer

    When not fighting web crime, Jason Seifer is a teacher at Treehouse. He's passionate about the web and programming. You can find Jason on Twitter at @jseifer and on his personal blog at jasonseifer.com.