Skip to content

Instantly share code, notes, and snippets.

@chobie
Created February 22, 2011 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chobie/838706 to your computer and use it in GitHub Desktop.
Save chobie/838706 to your computer and use it in GitHub Desktop.
# 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