Skip to content

Instantly share code, notes, and snippets.

%%$@_$^__#)^)&!_+]!*@&^}@[@%]()%+$&[(_@%+%$*^@$^!+]!&_#)_*}{}}!}_]$[%}@[{_@#_^{*
@##&{#&{&)*%(]{{([*}@[@&]+!!*{)!}{%+{))])[!^})+)$]#{*+^((@^@}$[**$&^{$!@#$%)!@(&
+^!{%_$&@^!}$_${)$_#)!({@!)(^}!*^&!$%_&&}&_#&@{)]{+)%*{&*%*&@%$+]!*__(#!*){%&@++
!_)^$&&%#+)}!@!)&^}**#!_$([$!$}#*^}$+&#[{*{}{((#$]{[$[$$()_#}!@}^@_&%^*!){*^^_$^
]@}#%[%!^[^_})+@&}{@*!(@$%$^)}[_!}(*}#}#___}!](@_{{(*#%!%%+*)^+#%}$+_]#}%!**#!^_
)@)$%%^{_%!@(&{!}$_$[)*!^&{}*#{!)@})!*{^&[&$#@)*@#@_@^_#*!@_#})+[^&!@*}^){%%{&#@
@{%(&{+(#^{@{)%_$[+}]$]^{^#(*}%)@$@}(#{_&]#%#]{_*({(])$%[!}#@@&_)([*]}$}&${^}@(%
(%[@%!}%*$}(*@)}){+@(%@*$&]*^*}*]&$[}*]%]+*}^!}*$^^_()#$^]++@__){&&+((#%+(&+){)$
%&&#($[[+##*%${)_!+{_[})%++)$#))]]]$]@]@($+{&%&%+!!!@]_]+])^*@$(@#${}}#}{%}#+{(@
#__+{{]${]!{(%${%%^)(_*_@+)$]$#_@$)]](}{}$(}*%+!}#+)$%$}+#@*&^{##}+@(%[*@_}{(^]^
@iluwatar
iluwatar / git_merge_tags.sh
Created February 21, 2015 11:27
git_merge_tags
cd <work dir>/<dst repository>
git remote add -f <src repository1> <work dir>/<src repository1>
git fetch -t <src repository1>
git checkout -b <tag> tags/<tag>
git merge --no-edit tags/<tag>
git remote rm <src repository1>
git remote add -f <src repository2> <work dir>/<src repository2>
git fetch -t <src repository2>
git merge --no-edit tags/<tag>
git remote rm <src repository2>
@iluwatar
iluwatar / git_merge_branches.sh
Created February 21, 2015 11:25
git_merge_branches
cd <work dir>/<dst repository>
git remote add -f <src repository1> <work dir>/<src repository1>
git fetch -n <src repository1>
git checkout <branch>
git branch --set-upstream <branch> <src repository1>/<branch>
git merge --no-edit <src repository1>/<branch>
git remote rm <src repository1>
git remote add -f <src repository2> <work dir>/<src repository2>
git fetch -n <src repository2>
git branch --set-upstream <branch> <src repository2>/<branch>
@iluwatar
iluwatar / git_merge_master.sh
Created February 21, 2015 11:23
git_merge_master
cd <work dir>
git clone <dst repository url>
cd <work dir>/<dst repository>
git remote add -f <src repository> <work dir>/<src repository>
git merge -m "Merge to the combined repository." <src repository>/master
git remote rm <src repository>
git push origin master
@iluwatar
iluwatar / git_rewrite_history.sh
Created February 21, 2015 11:19
git_rewrite_history
git filter-branch --index-filter \
'git ls-files -s | sed "s-\t\"*-&myfolder/-" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"
' --tag-name-filter cat -f -- --all
@iluwatar
iluwatar / git_cleanup_repository.sh
Created February 21, 2015 11:17
git_cleanup_repository
git filter-branch --tag-name-filter cat --index-filter 'git rm -r --cached --ignore-unmatch bigfolder' --prune-empty -f -- --all
git filter-branch --tag-name-filter cat --index-filter 'git rm --cached --ignore-unmatch somefolder/bigfile.zip' --prune-empty -f -- --all
@iluwatar
iluwatar / git_deep_clone_repository.sh
Last active August 29, 2015 14:15
git_deep_clone_repository
cd <work dir>
git clone <src repository url>
cd <work dir>/<src repository>
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
git branch --track ${branch##*/} $branch
done
git remote rm origin
@iluwatar
iluwatar / .bashrc
Last active August 29, 2015 14:10
With Maven and Java environment variables
#MAVEN
M2_HOME=/opt/apache-maven-3.2.3
export M2_HOME
M2=$M2_HOME/bin
export M2
PATH=$M2:$PATH
export PATH
# JAVA
@iluwatar
iluwatar / setup_iptables.sh
Created November 19, 2014 19:35
Basic iptables firewall (CentOS 6)
#!/bin/bash
# Flush all current rules from iptables
iptables -F
ip6tables -F
# Allow SSH connections on the following tcp ports
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT