Skip to content
CassieW edited this page Nov 4, 2015 · 3 revisions

Some helpful terminal/git commands

If something doesn't work, remember to "bundle install"!

To switch branches

git checkout "branch_name"

How to create a new branch

  • git checkout master
  • git checkout -b branch_name

To commit to my own branch AND push changes to origin branch_name

  • git add .
  • git status
  • git commit -m "comments go here!"
  • git push -u origin karma_kai

To merge branch changes back to master

  • git checkout master
  • git merge karma_kai
  • git push -u origin master

push to heroku from master branch

  • heroku login
  • git push heroku master
  • heroku run rake db:migrate
  • heroku ran rake db:seed
  • heroku apps:info

to run rails app locally on cloud9 IDE

  • bundle install
  • rails server -b $IP -p $PORT

To pull new changes on origin master to your local master branch

  • git checkout master
  • git pull // side note: "git pull" does fetch + merge for you.

To update karma_kai branch with new updates on the local repo ( master ) branch.

  • git checkout karma_kai // may have to do "git checkout -f karma_kai"
  • git merge master // merge changes on master to branch
  • git push -u origin karma_kai

To rename heroku app domain name

  • heroku login
  • heroku apps:rename newname --app oldname
  • git remote rm heroku // next 2 lines updates remotes
  • heroku git:remote -a newname

How to undo/destroy a scaffold

  • rake db:migrate:down VERSION=20151203124
  • rake destroy scaffold User

How to commit deleted files

  • git add -u
  • git commit -am "comments"
  • git push -u origin master

How to commit untracked files

  • git add -A :/
  • git commit -am "comments"
  • git push -u origin karma_kai

How to generate new migration to add new columns to a table in DB

  • rails generate migration add_points_to_users points:integer
  • rake db:migrate

how to add new entry to DB from terminal

  • rails console
  • User.create(name: "Kai Kuroda",email: "asdf", points: 0)
  • exit

how to fix ActiveRecord::PendingMigrationError after changing migration files [rake aborted! StandardError: An error has occurred, this and all later migrations canceled:]

  • //If you DON'T mind erasing data:
  • rake db:drop
  • rake db:create
  • rake db:migrate

How to reset heroku DB

  • heroku pg:reset DATABASE --app karma2