(1) Create a ".gitignore" file at the root level of your ruby project. 

(2) Edit the file and place the list of files and directories to ignore. E.g.

# Ignore bundler config.
/.bundle

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

.byebug_history
/.rubocop_todo.yml
/config/api_key.yml
/doc/

# Ignore encrypted secrets key file.
config/secrets.yml.key

If you are using IDE such as Rubymine, you can install the .ignore plugin and use it to automatically create the .gitignore file with the built-in template for Ruby.