Skip to content

Instantly share code, notes, and snippets.

@dubbs
Last active June 23, 2016 13:46
Show Gist options
  • Save dubbs/4728374 to your computer and use it in GitHub Desktop.
Save dubbs/4728374 to your computer and use it in GitHub Desktop.
Commands

GIT

reset local branch to HEAD of remote

git fetch --all
git reset --hard origin/mybranch

MYSQL

setup user and database

mysql -u root -p
CREATE DATABASE db;
CREATE USER 'user'@'localhost' IDENTIFIED BY 'pass';
GRANT USAGE ON *.* TO 'user'@localhost IDENTIFIED BY 'pass';
GRANT ALL ON 'db'.* TO 'user'@localhost;
mysql -u 'user' -p'pass' db

rename database

mysqldump -u root -p mydb > ~/mydb.sql
mysql -u root -p
CREATE DATABASE `mynewdb`;
\. ~/mydb.sql

dump database

mysqldump -u user --complete-insert --create-options --quote-names mydb

dump single table

mysqldump -u user --complete-insert --no-create-info --skip-comments --create-options --quote-names mydb mytable

search through files

grep -r "<<<<" .

tar test/ contents

tar -zcvf test.tgz -C test .

copy to remote

scp test.tgz user@remote:/path/to/dest

removing files

find . -iname .DS_Store -delete

rename multiple files

brew install rename rename 's/^old/new/' old*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment