Skip to content

Instantly share code, notes, and snippets.

@ghanbak
Last active May 24, 2017 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghanbak/6942132 to your computer and use it in GitHub Desktop.
Save ghanbak/6942132 to your computer and use it in GitHub Desktop.
Command Line snippets and Git commands

command-line

COMMAND LINE

Local Dev

http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/

WTF Apache?

apachectl configtest

Put a Date in your File Name

api_staging_magento-$(date +%d-%m-%Y_%H-%M-%S).sql

No need to look at your clock and/or calendar. Just use the above example to get down to the second file names.


Find file

grep -rl termyoursearchingforinafile ~/

MYSQL Dump

Export

 mysqldump --opt -Q --order-by-primary -u mysql_user -p DATABASE_NAME > backup.sql

Import

 mysql -u mysql_user -p DATABASE < backup.sql

rsync

Basic Local to Remote rsync

rsync -avrztp  --progress --rsh="ssh -p33322" file.name user@123.456.78.90:/path/to/file

Basic Remote to Local rsync

rsync -avrztp  --progress --rsh="ssh -p33322" user@123.456.78.90:/path/to/file/file.name /path/to/file

Exclude files

rsync --exclude="file.name /folder-name" ...

github

GITHUB

Remove all deleted files

git rm $(git ls-files --deleted)

Git Assume Unchanged

git update-index --assume-unchanged <file>

For reverting said file to be committed.

git update-index --no-assume-unchanged <file>

Git Repo Merging with Retained Commit Histories

# 
# Basic process for merging two Git repositories while retaining commit history.
# - This seems to work pretty well for migrations to Pantheon
#

# Clone the repository that will be the final origin
git clone <repository_uri_1> <local_dir>
cd <local_dir>

# Add the second repository as a remote
git remote add <remote_name> <repository_uri_2>
git fetch <remote_name>

# Create a new branch based off the secondary repository
git branch <branch_name> <remote_name>/<remote_branch>
git checkout <branch_name>

#
# Perform any modifications to this branch that need to be done
# before merging into the final repository.
#

# Merge the secondary repository branch into the final repository and clean up.
git checkout master
git merge <branch_name>
git branch -D <branch_name>
git remote remove <remote_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment