Created
February 22, 2011 14:06
-
-
Save chobie/838706 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git リポジトリ内でそれっぽいディレクトリ名に移動する | |
function j() | |
{ | |
top_dir=`git rev-parse --show-cdup` | |
path=`git ls-tree -rd --name-only --full-tree $(git rev-parse HEAD) | grep ${1}$` | |
result=$? | |
if [ ${result} -eq 0 ]; then | |
echo "# jumping to [${path}]"; | |
cd ${top_dir}${path} | |
pwd | |
else | |
echo "path {$1} not found." | |
fi | |
} | |
# untracked, modifiedなファイルを転送する | |
# scpだと複数ファイルやったときに遅いのでそのうちssh+tarにする | |
function git_upload_files() | |
{ | |
server_name="your_server_name" | |
home_path="server_upload_base_path" | |
top_dir=`git rev-parse --show-cdup` | |
if [ -n "${top_dir}" ]; then | |
targets=`cd ${top_dir} && git ls-files -o -m --full-name` | |
else | |
targets=`git ls-files -o -m` | |
fi | |
if [ -n "${targets}" ]; then | |
if [ -n "${top_dir}" ]; then | |
(cd ${top_dir} && echo "${targets}" | xargs -n1 -i scp -C {} ${server_name}:${home_path}{}) | |
else | |
(echo "${targets}" | xargs -n1 -i scp -C {} ${server_name}:${home_path}{}) | |
fi | |
else | |
echo "nothing to upload" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment