Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
149 lines (100 sloc) 4.37 KB
layout title permalink
default
How to Push to GitHub
github

Push Your App to GitHub

Created by Alyson La, @realalysonla

Things you need before you get started

Git & GitHub

  • Check if Git is installed

    • In the terminal type git --version (1.8 or higher preferred)
  • If not, download Git here. Then, setup your local Git profile - In the terminal:

    • Type git config --global user.name "your-name"

    • Type git config --global user.email "your-email"

    • To check if Git is already config-ed you can type git config --list

  • Create a free GitHub account or login if you already have one

COACH: Talk a little about git, version control, and open source

Push your app to GitHub using the command line

On your GitHub profile click "new repo" screen shot 2013-06-01 at 12 38 50 pm give it a name (example: rails-girls), brief description, choose the "public" repo option, and click "create repository".

In the command line--make sure you cd into your railgirls folder--and type:

{% highlight sh %} git init {% endhighlight %}

This initializes a git repository in your project

Note: If you've already done the Heroku guide, then you've already initialized a git repository & you can move on to the next steps.

Next check if a file called README.rdoc exists in your railsgirls directory:

{% highlight sh %} ls README.rdoc {% endhighlight %}
{% highlight sh %} dir README.rdoc {% endhighlight %}

If the file doesn't exist, create it by typing:

{% highlight sh %} touch README.rdoc {% endhighlight %}
{% highlight sh %} type nul > README.rdoc {% endhighlight %}

COACH: Talk a little about README.rdoc

Then type:

{% highlight sh %} git status {% endhighlight %}

This will list out all the files in your working directory.

COACH: Talk about some of your favorite git commands

Then type:

{% highlight sh %} git add . {% endhighlight %}

This adds in all of your files & changes so far to a staging area.

Then type:

{% highlight sh %} git commit -m "first commit" {% endhighlight %}

This commits all of your files, adding the message "first commit"

Next type:

{% highlight sh %} git remote add origin https://github.com/username/rails-girls.git {% endhighlight %}

Your GitHub Repository page will list the repository URL, so feel free to copy and paste from there, rather than typing it in manually. You can copy and paste the link from your GitHub repository page by clicking the clipboard icon next to the URL.

This creates a remote, or connection, named "origin" pointing at the GitHub repository you just created.

Then type:

{% highlight sh %} git push -u origin master {% endhighlight %}

This sends your commits in your "master" branch to GitHub

Congratulations your app is on GitHub! Go check it out by going to the same url you used above: https://github.com/username/rails-girls (without the .git part)

If you want to continue making changes and pushing them to GitHub you'll just need to use the following three commands:

{% highlight sh %} git add . git commit -m "type your commit message here" git push origin master {% endhighlight %}

COACH: Talk about what makes a good commit message (active, descriptive and short).

What's next?

Be a Part of the Open Source Community

  • Follow your fellow Rails Girls & coaches on GitHub
  • Star or watch their projects
  • Fork a repo, then clone and push changes to your fork. Share the changes with the originator by sending them a pull request!
  • Create an issue on a project when you find a bug
  • Explore other open source projects - search by programming language or key word

Learn more Git

{% include other-guides.md page="github" %}

You can’t perform that action at this time.