Last active
August 29, 2015 14:03
-
-
Save ryanholm/906037153c043d3cc19d to your computer and use it in GitHub Desktop.
Basic Commands Reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
host $ git clone https://github.com/rails/rails-dev-box.git | |
host $ cd rails-dev-box | |
host $ vagrant up | |
vagrant up - start Vagrant | |
vagrant ssh - log in to Vagrant | |
vagrant halt - shut down Vagrant | |
vagrant reload - restarts Vagrant | |
vagrant status - print the current status of Vagrant | |
vagrant suspend - suspends Vagrant, rather than shutting it down. | |
vagrant resume - resumes your Vagrant machine after it has been suspended. | |
$ pwd #=> print working directory | |
$ ls #=> list all files and subdirectories in the current directory | |
$ ls -l #=> list all files and subdirectories in the current directory, but with more details | |
$ mkdir code #=> make a new directory named "code" | |
$ cd code #=> navigate into the "code" directory | |
$ pwd #=> validate that you are now in the code directory | |
$ cd .. #=> move up one level in the directory tree | |
$ cd code #=> navigate back into the "code" directory | |
$ open . #=> open the finder window for the current directory, if you're using Windows, replace "open" with "start" or "explorer" | |
$ man mkdir #=> view the manpage (manual) for the mkdir command | |
$ q #=> exit out of the manpage (q stands for "quit") | |
$ touch snippets.rb #=> create a new file in the current directory, named snippets.rb | |
$ ls -l #=> validate that snippets.rb was created | |
$ cat snippets.rb #=> view the contents of snippets.rb | |
$ echo hello world #=> print something | |
$ echo puts \"hello world\" > snippets.rb #=> print a statement into the snippets.rb file | |
$ cat snippets.rb #=> view snippets.rb contents | |
$ cp snippets.rb hello.rb #=> make a copy of snippets, named hello | |
$ mv hello.rb helloworld.rb #=> rename hello to helloworld | |
$ rm helloworld.rb #=> delete helloworld | |
$ ls -l #=> view the contents of the current directory | |
$ grep hello snippets.rb #=> search the snippets file for the hello string | |
$ cd .. #=> move up one level | |
$ grep -r e code | |
$ mkdir temp #=> make a temp directory | |
$ cp temp temp2 #=> try to make a copy of temp, named temp2 (won't work) | |
$ rm temp #=> try to delete temp (won't work) | |
$ cp -r temp temp2 #=> make a copy of temp, named temp2 (recursively) | |
$ rm -r temp2 #=> delete temp2 (recursively) | |
$ ls -l temp | |
$ git config --global user.name "Your Name" | |
$ git config --global user.email "[email protected]" | |
$ git config --global color.ui true | |
$ mkdir git_test | |
$ cd git_test | |
Initialize a new Git repository with git init and create an empty file called readme.txt with touch. | |
$ git init | |
$ touch readme.txt | |
$ open readme.txt | |
This is the first line of text | |
This is the second line of text | |
$ git status | |
$ git add readme.txt | |
$ git status | |
$ git add . | |
$ git commit -m 'second commit' | |
$ git log | |
$ git checkout -b new-branch | |
Check the status to prove that you're in a new branch. | |
$ git status | |
Open the readme.txt file, and you'll see that it contains the same content that was saved in the master branch. Add the line stated below, then stage and commit the change. | |
$ open readme.txt | |
This is a new branch. | |
$ git add . | |
$ git commit -m 'Added a line in a new branch' | |
Switch back to the master branch using the checkout command, and open readme.txt: | |
$ git checkout master | |
$ open readme.txt | |
You'll see that the change you just committed is not there because it only exists in the new-branch branch. | |
To add the change from new-branch to master, run the git merge command from the master branch. The change will be automatically committed to the master branch, but you can run git status to be sure. Open the readme.txt file to see the change you made in new-branch. | |
$ git merge new-branch | |
$ git status | |
$ open readme.txt | |
Once you are finished making changes in branch, it's best to delete the branch to keep your Git repository clean. This can be done using the -d option on git branch. | |
$ git branch -d new-branch | |
You can delete an un-merged branch using a capital "D": | |
$ git branch -D unmerged-branch | |
#Steps when making a new repository | |
#1 | |
$ mkdir first-repo | |
$ cd first-repo | |
# 2 Create a new repository on the command line (inside directory) | |
touch README.md | |
git init | |
git add README.md | |
git commit -m 'first commit' | |
git remote add origin https://github.com/ryanholm/first-repo.git | |
git push -u origin master | |
Git and Deploy | |
$ git status | |
$ git add . | |
$ git commit -m 'Implemented favoriting' | |
$ git push | |
$ git push heroku master | |
$ heroku run rake db:migrate | |
command + SHFT + F = global find | |
rake routes | grep devise (great way to rake routes with querying only devise items) | |
#creating a new branch | |
git branch #tells you what branch you're on. | |
git checkout -b 'name of branch to track edits' | |
*message that you're on the new branch | |
*tracks your edits in terminal/code editor | |
#merging branch | |
$ git diff # hit 'q' to exit | |
$ git add . | |
$ git add -u . # stage deleted files as well | |
$ git status # check that all files, added and deleted, are staged | |
$ git commit -m 'Associated and nested topics and posts.' | |
$ git checkout master | |
$ git merge nesting-posts | |
$ git push | |
$ git branch -d nesting-posts #prune | |
#To remove a local branch from your machine: | |
git branch -d the_local_branch | |
#To remove a remote branch: | |
git push origin :the_remote_branch | |
*Taken from here: https://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote | |
http://railscasts.com/episodes/66-custom-rake-tasks | |
➜ checklist git:(master) rake -T (Great Source for understanding Rake and custom Rake Tasks you've created). | |
rake about # List versions of all Rails frameworks and the environment | |
rake assets:clean[keep] # Remove old compiled assets | |
rake assets:clobber # Remove compiled assets | |
rake assets:environment # Load asset compile environment | |
rake assets:precompile # Compile all the assets named in config.assets.precompile | |
rake cache_digests:dependencies # Lookup first-level dependencies for TEMPLATE (like messages/show or... | |
rake cache_digests:nested_dependencies # Lookup nested dependencies for TEMPLATE (like messages/show or comm... | |
rake cucumber # Alias for cucumber:ok | |
rake cucumber:all # Run all features | |
rake cucumber:ok # Run features that should pass | |
rake cucumber:rerun # Record failing features and run only them if any exist | |
rake cucumber:wip # Run features that are being worked on | |
rake db:create # Create the database from DATABASE_URL or config/database.yml for th... | |
rake db:drop # Drops the database using DATABASE_URL or the current Rails.env (use... | |
rake db:fixtures:load # Load fixtures into the current environment's database | |
rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog) | |
rake db:migrate:status # Display status of migrations | |
rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STE... | |
rake db:schema:cache:clear # Clear a db/schema_cache.dump file | |
rake db:schema:cache:dump # Create a db/schema_cache.dump file | |
rake db:schema:dump # Create a db/schema.rb file that can be portably used against any DB... | |
rake db:schema:load # Load a schema.rb file into the database | |
rake db:seed # Load the seed data from db/seeds.rb | |
rake db:setup # Create the database, load the schema, and initialize with the seed ... | |
rake db:structure:dump # Dump the database structure to db/structure.sql | |
rake db:version # Retrieves the current schema version number | |
rake doc:app # Generate docs for the app -- also available doc:rails, doc:guides (... | |
rake log:clear # Truncates all *.log files in log/ to zero bytes (specify which logs... | |
rake middleware # Prints out your Rack middleware stack | |
rake notes # Enumerate all annotations (use notes:optimize, :fixme, :todo for fo... | |
rake notes:custom # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM | |
rake rails:template # Applies the template supplied by LOCATION=(/path/to/template) or URL | |
rake rails:update # Update configs and some other initially generated files (or use jus... | |
rake routes # Print out all defined routes in match order, with names | |
rake secret # Generate a cryptographically secure secret key (this is typically u... | |
rake stats # Report code statistics (KLOCs, etc) from the application | |
rake test # Runs test:units, test:functionals, test:integration together | |
rake test:all # Run tests quickly by merging all types and not resetting db | |
rake test:all:db # Run tests quickly, but also reset db | |
rake test:recent # Run tests for {:recent=>["test:deprecated", "test:prepare"]} / Depr... | |
rake test:uncommitted # Run tests for {:uncommitted=>["test:deprecated", "test:prepare"]} /... | |
rake time:zones:all # Displays all time zones, also available: time:zones:us, time:zones:... | |
rake tmp:clear # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:ses... | |
rake tmp:create # Creates tmp directories for sessions, cache, sockets, and pids | |
You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing rake --tasks. Each task has a description, and should help you find the thing you need. | |
http://guides.rubyonrails.org/command_line.html#rake | |
#Gives you the list of Controllers that you are can generate below. | |
➜ checklist git:(master) rails generate | |
Usage: rails generate GENERATOR [args] [options] | |
General options: | |
-h, [--help] # Print generator's options and usage | |
-p, [--pretend] # Run but do not make any changes | |
-f, [--force] # Overwrite files that already exist | |
-s, [--skip] # Skip files that already exist | |
-q, [--quiet] # Suppress status output | |
Please choose a generator below. | |
Rails: | |
assets | |
controller | |
generator | |
helper | |
integration_test | |
jbuilder | |
mailer | |
migration | |
model | |
resource | |
scaffold | |
scaffold_controller | |
task | |
ActiveRecord: | |
active_record:devise | |
Coffee: | |
coffee:assets | |
Cucumber: | |
cucumber:install | |
Devise: | |
devise | |
devise:install | |
devise:views | |
Jquery: | |
jquery:install | |
Js: | |
js:assets | |
Mongoid: | |
mongoid:devise | |
Rspec: | |
rspec:feature | |
rspec:install | |
rspec:observer | |
TestUnit: | |
test_unit:controller | |
test_unit:helper | |
test_unit:integration | |
test_unit:mailer | |
test_unit:model | |
test_unit:plugin | |
test_unit:scaffold |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://guides.rubyonrails.org/getting_started.html