Skip to content

Instantly share code, notes, and snippets.

@bigandy
Last active February 6, 2017 18:08
Show Gist options
  • Save bigandy/6621428665f2eaf52c57 to your computer and use it in GitHub Desktop.
Save bigandy/6621428665f2eaf52c57 to your computer and use it in GitHub Desktop.
Useful CLI Commands
# Prevent need for sudo npm install ...
sudo chown -R `whoami` ~/.npm
# Allow updating of Themes, plugins, Core in WordPress
sudo chown -R andrew:_www <site>
# Copy file from one location to another
# in this case the wordpress template into the test folder
cp -R source/wp test
# File name change
mv wp-config-sample.php wp-config.php
# Find all devices on local network
arp -a
# Copy .ssh key to clipboard
pbcopy < ~/.ssh/id_rsa.pub
# Flush DNS
sudo killall -HUP mDNSResponder
# ST3 subl .
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
# Git submodule Initial pulldown
git submodule init
git submodule update
# Symlink nginx server block
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
# Backup database
mysqldump -u root -p db-name > db_backup.sql
# Import database
mysql -p -u root database_name < file.sql
# phpmyadmin setting for name of database with timestamp
@DATABASE@-%F-%T
# Delete Remote Git Branch
git push origin --delete <branchName>
# Delete Local Git Branch
git branch -d <branchName>
# update npm
sudo npm install npm -g
# update all git submodules, inclusive of sub-submodules
git submodule update --init --recursive
# Amend last git commit
git commit --amend -m "New commit message"
git commit --amemd
# Find all .less files in folder but not node_modules
find . -name "*.less" -not -path "./node_modules/*"
# Undo last commit (if not pushed to origin)
git reset --soft HEAD^
# Unstage file after adding
git reset <filename>
# Run git commit without pre-commit hook
git commit -m "here is my message" --no-verify
# Remove from git but keep folder
git rm --cached -r somedir
# Delete all .svn folders within current folder
find . -name .svn -exec rm -rf '{}' \;
# Add ssh pass to keychain
ssh-add -K ~/.ssh/id_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment