Skip to content

Instantly share code, notes, and snippets.

@miwillhite
Created June 12, 2011 03:32
Show Gist options
  • Save miwillhite/1021225 to your computer and use it in GitHub Desktop.
Save miwillhite/1021225 to your computer and use it in GitHub Desktop.
Rails command prompt cheat sheet
# A little about the syntax for common commands
#
# When you call something like `ruby`, `git` or `rvm` in the command line
# you are really just executed a small program (or command). The first thing
# you type is the name of the command, for example "git". Everything following
# that are arguments for the command, separated by a space.
#
# Each command takes arguments differently, so you have to view the documentation
# to figure it out. You can view documentation on the commands by typing `man [command-name]`
# That fires a program called "man" with an argument of the command you want to learn about
# and renders documentation for the various arguments.
#
# There are many shortcuts, here are a few of the really helpful ones:
# ls - Show all of the files and folders in the current directory
# cd [dir] - Change directory, enter the name of the directory; e.g. `cd projects`, `cd ..` (goes back up one directory)
# history - Shows previously entered commands
# open [dir] - Opens the specified directory or file; e.g. `open Phoenix`, `open .` (opens current directory in Finder)
# ↑ - Enter the previous command (continues through the history)
#
# =======================
# = Current Environment =
# =======================
# Verify the ruby version
# e.g. ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
#
ruby -v
# Verify the RVM Gemset
# e.g. Phoenix
#
rvm gemset name
# ================
# = Git Workflow =
# ================
# Get current branch, indicated by asterisk
# e.g.
# development
# * master
# build
#
git branch
# Switch to another existing branch
# e.g. git checkout development
#
git checkout [branch-name]
# Create a new branch and switch to it
# e.g. git checkout -b design-update
#
git checkout -b [branch-name]
# Merge one branch into another branch
# If you created your own branch, then decided to merge it back into development, use this process:
#
# (say your branch is named 'design-update' and that is the branch you are currently on)
#
# git rebase development (<- where 'development' is the branch that you created yours from)
# git checkout development
# git merge design-update
#
git merge [branch-name]
# Pull down the latest from github
# `--rebase` is an argument (or flag) that merges the repository
# contents in a way that keeps the version history clean
#
git pull --rebase
# ===========
# = Bundler =
# ===========
# Bundler is used to mange the gems that your project uses
# It uses Gemfile as its instructions on what to install and from where
# Install/Update the project gems (this will download any gems that haven't been
# installed elsewhere on the computer)
#
bundle
# Run system commands in the scope of your bundled gems
#
# If you see a message like this when running something like `rake`:
# "You have already activated [gem name/version], but your Gemfile requires
# [gem name/version]. Consider using bundle exec."
#
# Then you may need to run the command prefixed with `bundle exec`
# i.e. bundle exec rake db:migrate
#
bundle exec [system-command arguments]
# ========
# = Rake =
# ========
# Rake is a general utitility that performs chores for the user, it is used throughout Rails
# Run migrations
#
rake db:migrate
# Wipe out the database and run migrations
#
rake db:migrate:reset
# Seed the database with pre-defined dummy data
#
rake db:seed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment