git 打包的一个bash 函数

Here is my bash alias. The argument is the <branch name> to export.
An example:

cd /path/to/foo/
_gittar master

The output is (time in ISO 8601 / UTC):

../foot-YYYYMMDD.HHMM.tar.gz

function _gittar ()
{
local name=$(pwd)
name=${name##*/}

if [ ! "$1" ]; then
echo "[ERROR] what branch to export?"
return 1
fi

local date=$(TZ=UTC date '+%Y%m%d.%H%M')
local pkg="$name-$date"
local dir=".."
local tar="$dir/$pkg.tar.gz"

git archive /
--format=tar /
--prefix="$pkg/" /
"$@" |
gzip --best > "$tar"

echo $tar
}

你可能感兴趣的:(Date,git,bash,branch,output,archive)