Skip to content

Instantly share code, notes, and snippets.

@jtdp
jtdp / gist:5444879
Created April 23, 2013 15:58
Dump mysql database to gzipped file
mysqldump -uroot -p database_name | gzip > database_name_file.sql.gz
@jtdp
jtdp / gist:5443498
Last active January 24, 2024 08:59
Revert file permission changes in local git repository.. Very useful when you change permissions due to working on a samba share. Lifted from: http://stackoverflow.com/questions/2517339/git-how-to-recover-the-file-permissions-git-thinks-the-file-should-be
git diff -p \
| grep -E '^(diff|old mode|new mode)' \
| sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' \
| git apply
@jtdp
jtdp / gist:5443442
Created April 23, 2013 13:12
Adding a submodule in git
git submodule add <remote-url> <directory>
@jtdp
jtdp / gist:5443429
Created April 23, 2013 13:09
Cloning a git repository with submodules
# clone the repository
git clone <remote-url>
# cd into the directory created
cd <dir>
# init submodules
git submodule init
# update submodules - this is where the code is pulled in
@jtdp
jtdp / gist:5443305
Last active December 16, 2015 13:39
Git remove file but keep local copy. Note that when other repository clones pull from the same remote, their local copy of the file will be deleted unless they have modified it.
git rm --cached <filename>
@jtdp
jtdp / gist:5443297
Last active March 13, 2024 12:58
See changes before pulling from remote git repository
# fetch the changes from the remote
git fetch origin
# show commit logs of changes
git log master..origin/master
# show diffs of changes
git diff master..origin/master
# apply the changes by merge..
@jtdp
jtdp / gist:5443290
Created April 23, 2013 12:49
Change remote url of git repository
git remote set-url origin <remote-url>
@jtdp
jtdp / gist:4086339
Created November 16, 2012 10:44
Add unversioned resources to svn
svn status | grep "?" | awk '{print $2}' | xargs svn add