Last active
February 2, 2021 13:10
-
-
Save bradbajuz/9e9dcbfc37099e3dac52 to your computer and use it in GitHub Desktop.
Git, Rails and VIM Cheat Sheet
This file contains hidden or 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
GIT COMMANDS | |
First Commit | |
$ git init | |
$ git add . | |
$ git commit -m "Initial commit" | |
$ git remote add origin [git address] | |
$ git push -u origin master | |
Branches | |
$ git checkout -b [name of branch] | |
$ git push origin branch-name | |
$ git checkout master | |
$ git merge [name of branch] | |
Delete Branch | |
$ git branch -d <branchName> | |
$ git push origin --delete <branchName> | |
ReadMe | |
$ git mv README.rdoc README.md | |
$ git commit -a -m "Improve the README" | |
Regular Commands | |
$ git status | |
$ git add . | |
$ git commit -m "Finish demo app" | |
$ git push | |
Clear Git Cache | |
$ git rm -r --cached . | |
$ git add . | |
$ git commit -m ".gitignore is now working" | |
$ git reset --hard HEAD | |
Tags | |
git tag | |
git show | |
git tag -a v1.0 -m "Release 1.0" | |
git push --tags | |
HEROKU | |
$ heroku keys:add ~/.ssh/id_rsa.pub | |
$ heroku create --stack cedar | |
$ git push heroku master | |
$ heroku git:remote -a <app-name> | |
$ heroku run rake db:migrate | |
$ rake figaro:heroku | |
BUNDLER | |
gem install bundler (for each version of Ruby) | |
bundle update | |
bundle install | |
rbenv rehash | |
brew update | |
gem update | |
gem install bundler | |
rbenv exec gem install rails --version 5.1.0 --no-ri --no-rdoc | |
RAILS | |
rake db:reset db:migrate | |
rake db:drop db:create db:migrate | |
pg_restore -d database_name -c file_name.tar | |
pg_restore -d physician-portal_development -c export | |
rails g migration AddUserToHotlists user_id:integer:index | |
Rails 5: | |
rails g migration AddProviderToPfOrders provider:references | |
create_table :educations do |t| | |
t.belongs_to :profile, index: true, foreign_key: true | |
end | |
Reset database table and primary key index | |
ActiveRecord::Base.connection.truncate(:table_name) | |
ActiveRecord::Base.connection.reset_pk_sequence!('table_name') | |
RAILS ASSETS | |
rm -rf tmp/cache | |
rake tmp:cache:clear | |
rake assets:clobber | |
bundle exec rake assets:precompile | |
RAILS CREDS | |
EDITOR="subl --wait" bin/rails credentials:edit | |
DOCKER | |
Check logs: | |
docker ps | |
docker stop <container_ID> | |
docker system prune | |
docker attach <container> | |
DOKKU | |
Restore database | |
gunzip -c <db_backup.gz> | dokku postgres:import <db_name> | |
dokku postgres:import db_marketingapp < export | |
dokku plugin:update letsencrypt | |
PUMA SERVER: | |
[::1]:3000 | |
rails s -b $(ipconfig getifaddr en0) | |
RUBY SERVER: | |
ruby -run -e httpd . -p 3000 | |
POSTGRESQL | |
select pg_size_pretty(pg_database_size('db_marketingapp')); | |
brew postgresql-upgrade-database | |
SSH | |
pbcopy < ~/.ssh/id_rsa.pub | |
FAIL2BAN | |
fail2ban-client status | grep "Jail list:" | sed "s/ //g" | awk '{split($2,a,",");for(i in a) system("fail2ban-client status " a[i])}' | grep "Status\|IP list" | |
GREP | |
top -p `pgrep process-name | tr "\\n" "," | sed 's/,$//'` | |
TERMINAL COMMAND TO MOST RECENT DIRECTORY | |
cdf | |
VIM COMMANDS//: | |
yy - Yank line (copy) | |
c3w - Cut 3 words | |
p - Paste below cursor | |
P - Paste above cursor | |
i - Insert text before cursor | |
a - Append text after cursor | |
fN - Jump forward to first 'N' | |
3fN - Jump forward to third 'N' | |
6l - Forward 6 letters | |
2j - Down 2 lines | |
vim -N filename - Open a file with Vim | |
:e . - Browse a directory | |
:e filename - Edit a file within Vim | |
:syntax enable - Enable syntax highlighting | |
:set syntax |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment