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
}
git 打包的一个bash 函数
最新推荐文章于 2023-03-07 14:09:32 发布