Skip to content

Instantly share code, notes, and snippets.

@da-n
da-n / gist:9770842
Last active August 29, 2015 13:57
Reset local repository to be just like remote repository

Setting your branch to exactly match the remote branch can be done in two steps:

git fetch origin
git reset --hard origin/master

If you want to save your current branch's state before doing this (just in case), you can do:

git commit -a -m "Saving my work, just in case"
git branch my-saved-work
@da-n
da-n / gist:9775065
Last active August 29, 2015 13:57
Remove directory from remote repository after adding them to .gitignore

The rules in .gitignore only apply to untracked files. If files under that directory have already been committed into the repository, unstage them, create a commit, and push that to master.

git rm -r --cached some-directory
git commit -m 'Remove the now ignored directory "some-directory"'
git push origin master

-- source http://stackoverflow.com/a/7927283/695454

@da-n
da-n / rsync-local-remote.md
Created April 3, 2014 15:57
rsync-local-remote

rsync local folders

rsync -rtv local_folder/ destination_folder/

rsync local to remote

rsync -rtv local_folder/ user@remoteserver.com:~/remote_folder/

@da-n
da-n / gist:10152321
Created April 8, 2014 16:31
htaccess password protect but not on localhost
Require valid-user
Allow from 127.0.0.1

Satisfy Any

@da-n
da-n / gist:ca585e14ff06c8fcdbb1
Last active August 29, 2015 14:01
Find out top 10 largest file/directories
$ du -ah /var | sort -n -r | head -n 10
@da-n
da-n / gist:42519b711df6cf2de29c
Last active August 29, 2015 14:01
Less is better, than tail
$ less +F log/production.log
# less +F works exactly like tail -f, with more:
#
# Simply press ctrl+c to switch to editing model, so you can scroll backward and using any more/vi command, such as /pattern to search
# Press shift+f again to switch back to tail model
# Anyway, just run man less to find some more information.
#
# source http://blog.libinpan.com/2009/07/less-is-better-than-tail/
@da-n
da-n / gist:3e3076190f1ba9eb095d
Created May 29, 2014 13:10
Brew update failed
$ cd $(brew --prefix)
$ git reset --hard HEAD
$ brew update
# if that fails, try this
$ cd $(brew --prefix)
$ sudo chown -R dan:staff $(brew --prefix)
$ rm Library/Formula/argp-standalone.rb
$ rm Library/Formula/cocot.rb
@da-n
da-n / gist:7f929f85316345eff7ff
Last active August 29, 2015 14:02
Enable mcrypt apache
# enable the mcrypt
$ sudo vim /etc/php5/apache2/php.ini
# Add this command in any line
extension=mcrypt.so
# Create conf.d folder in /etc/php5
@da-n
da-n / gist:536409c2c57a09a9d4e6
Created June 9, 2014 19:36
Setup dotfiles and vimfiles
git clone https://github.com/da-n/dotfiles .dotfiles && git clone https://github.com/da-n/vimfiles .vimfiles && cd .dotfiles &&./symlink.sh && cd ../.vimfiles && ./symlink.sh && cd
@da-n
da-n / gist:9bbaa92dc5ad546945f6
Created June 20, 2014 13:08
Rsync copy directory contents but not directory itself
$ rsync -av ~/foo/ user@remote.com:/var/www/bar/
# source http://stackoverflow.com/a/20301093