When developing an app, here's a common approach:

  1. You're working with some new code to get it to work
  2. You don't want to break your existing code, so you copy your current code to another folder (Folder A) and continue working in Folder B
  3. If you make a mistake, you just delete Folder B and resume with Folder A

This approach is the idea behind version control. Version control is a process that lets you keep checkpoints of your code so that you can refer back to them if needed.

Git is a widely-used version control system used to manage code. Code managed with Git is called a Git repository.

GitHub is popular hosting service for Git repositories. With GitHub, you can share your code and collaborate with others.


  1. In your project, initialize a Git repository:

    $ git init
  2. Check the status of which files and folders are new or have been edited:

    $ git status
  3. Tell Git to start tracking your files and folders:

    $ git add .

    If you want to track a single folder or file, use its name:

    $ git add app/
    $ git add config/routes.rb
  4. Verify that everything was committed correctly:

    $ git status
  5. Save the changes you made, with a message describing what changed:

    $ git commit -m "Initial commit"
  6. On GitHub, create a new repository with a short, memorable name:

  7. After creating a repository, copy the git commands under the "...or push an existing repository from the command line", and paste them into the terminal. These commands will add a remote repository, and then push your local repository to the remote repository.