Jun 15, 2015

[memo] How to show only total for each directories

du -csh *

The -c option can be added to provide a grand total for all of the files and directories that are listed.
The -s (for suppress or summarize) option tells du to report only the total disk space occupied by a directory tree and to suppress individual reports for its subdirectories.
The -h (i.e., human readable) can make the output easier to read by displaying it in kilobytes (K), megabytes (M) and gigabytes (G) rather than just in the default kilobytes.

Reference
http://stackoverflow.com/questions/10103604/linux-command-line-du-how-to-make-it-show-only-total-for-each-directories

Dec 9, 2014

[memo] How to change a git URL in all Jenkins jobs

Each job's configuration is saved at config.xml. So you just find old URL and change them to new URL like the below.


Sep 9, 2014

[memo] How to get hostname with logback

Just use ${HOSTNAME} logback can get hostname. Don't set hostname manually. It may make other engineers try to fix problem on other server. It's my experience. :)

Aug 13, 2014

[git] How to split repository by sub directories and retain all branches and tags

Because of Legacy and Enterprise code, I have a very big git repository moved from svn. If I build and deploy a external API's client, other clients are also updated and I should spent time to find why my war file has so many differences between current and new. If I fixed parent pom.xml, I could solve this problem. But I decided to split a big repository into 20 small repositories.

As usual, I Googled I found how to use git subtree to divide a sub directory to new git repository. It is very simple way!
Detach subdirectory into separate Git repository
 But it looses our commit logs and branches.

I asked Google again and found what I want.
git splitting repository by subfolder and retain all old branches
But I missed tags with this answer. Yes I know I should study myself. So I just added one more process to above.

Here is an example with github.

Make new repository on you github.
You can see how to push your project to new repository.
https://github.com/baepiff/test

git clone https://github.com/baepiff/voldemort voldemort
cd voldemort
git checkout --detach 
# delete all branches
git branch | grep --invert-match "*" | xargs git branch -D 
# get all branches
for remote in `git branch --remotes | grep --invert-match "\->"`; do
    git checkout --track $remote
done 
# confirm you have all branches and tags
git branch
git tag

# make another local repository
git clone voldemort voldemort2
cd voldemort2
git checkout --detach
git branch | grep --invert-match "*" | xargs git branch -D
for remote in `git branch --remotes | grep --invert-match "\->"`; do
    git checkout --track $remote
done
git branch
git tag 
# Isolate docs and recreate branches
# --prune-empty removes all commits that do not modify docs
# -- --all updates all existing references, which is all existing branches
git filter-branch --prune-empty --subdirectory-filter docs -- --all

# clean up git log
rm -rf .git/refs/original/*
git reflog expire --all --expire-unreachable=0
git repack -A -d
git prune

# push all branches and tags to new repository
git remote set-url origin https://github.com/baepiff/test
git push --all
git push --tags


I made separated repository shell script. I hope it helps you.
 

Jun 18, 2014

[git] how to change remote repository url

We have some development servers. We build source on the development on these servers. When I executed 'git fetch', git required another guy's password.

git fetch
#Password for 'https://another.guy@git.com':


Of course, I don't know his password. So I decided to change remote repository url. I got found the answer here.


git remote -v
#origin https://another.guy@git.com/scm/xxx.git (fetch)
#origin https://another.guy@git.com/scm/xxx.git (push)

git remote set-url origin https://git.com/scm/xxx.git

git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://git.com/scm/xxx.git (push)

git fetch
#Username for 'https://git.com/': my.user
#Password for 'https://my.user@git.com':


---
git remote set-url origin https://git.com/scm/xxx.git
git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://another.guy@git.com/scm/xxx.git (push)

git remote set-url --push origin https://git.com/scm/xxx.git
git remote -v
#origin https://git.com/scm/xxx.git (fetch)
#origin https://git.com/scm/xxx.git (push)

Jun 15, 2014

[git] how to remove remote tag

If you just started to use maven release plug in, you would get some problems with release plug in like failed on prepare due to not exist snapshot version, or failed on prepare because of existing tag. I would like to share how to remove git tag from remote.
It's easy. Just run the following commands. That's it!

git tag -d myapp-0.0.1
git push origin :refs/tags/myapp-0.0.1