Commands - acanyon/RubyTuesdays-ConnectFour GitHub Wiki
Quick command line reference. Here, and all over this wiki, when you see a $
at the beginning of the line that means it should go on the command line. If you see <filename>
, that means you should put the name of the file you want to manipulate in place of <filename>
. Same with <directory>
Move into a new folder/directory with cd
( change directory).
$ cd <directory> // puts you into <directory>
$ cd projects/ConnectFour // puts me into my connect four directory (for example)
$ cd .. // moves up into the directory one level up
List all the files and directories in a directory with ls
(list?)
$ ls // shows all files and directories
$ ls <directory> // shows all files/directories in <directory>
$ ls -a // shows all files & directories, including hidden files and directories (their names have . at the beginning)
Remove files or directories with rm
. Be careful! This is hard to undo!
$ rm <filename> // removes the file
$ rmdir <directory> // removes the directory
The windows command line application is called the command prompt. Because windows is a DOS-based system, some of the commands are different than mac. Check out this article for some tips. If you want a Unix-like command line (giving you all the mac commands!), you might want to try cygwin.
Windows commands different from above (feel free to add):
$ dir <directory-optional> // instead of ls
$ del <filename> // instead of rm
$ type <filename> // instead of cat
The command line application on mac is called Terminal. Mac is Unix-based, fun fact.
Bundler helps manage your project's gems and versions.
$ bundle install // installs all the gems listed in your Gemfile
$ bundle exec <command> // runs <command> in the context of your Gemfile
Rake (ruby make) is a tool that runs various useful tasks.
$ rake db:migrate // runs all the migrations on the database, updating it
$ rake db:test:prepare // sets up the test DB after any changes to the models
$ rails s // starts your server, accessible at http://localhost:3000 (ctrl+c to quit)
$ rails c // starts a rails console, essentially interactive rails with access to your database
// (type 'quit' to exit)
$ irb // starts an interactive ruby session - does not have access to database
// (type 'exit' to quit)
[RSpec](RSpec Tips & Tricks) runs your tests
$ rspec spec/ // runs all the tests in the project
$ rspec spec/model // runs all model tests
$ rspec spec/model/game_spec.rb // runs all tests in the game model spec
Git is turning into the version control to use these days, and if you're using github you're already using git! Many people have put a lot of time into git tutorials and guides, so this is going to be a very abbreviated list. If you have any interesting commands or tricks, feel free to put them here!
Common commands:
$ git add <filename> // 'stages' the file for commit
$ git rm <filename> // removes the file from the staging area
$ git commit -m "<message text>" // commits everything in your staging area with the given message
$ git diff --cached // creates a diff of everything in your staging area
$ git status // list of staged & unstaged-but-edited files
- Git Reference - site put together by the github team
- Interactive Git Branching Tutorial
- List of beginner git tutorials
- Current obsession: githug
vim is a command line text editor, and seems to be the one that git uses by default if, for example, you happen to try to commit without the -m
option. It's also frustrating if you've never seen it before. vim has its own little command line which is the only way to control it. Relatively comprehensive cheat sheet.
i // enter insert mode, allowing you to edit the text
ESC // 'escape' whatever mode you're in
:w // save changes
:q // quit vim (can be combined with write as :wq)