Help us understand the problem. What is going on with this article?

Git for Windowsなんだけどzipコマンド入ってないんだけど💢

More than 1 year has passed since last update.

git-archive使えば何とかなることに気付きました。
ちなみにunzipコマンドは標準で使えます。

mkdir workrepo
cd workrepo
git init
cp -r [target_file_or_dir] .
git add .
git commit -m commit
git archive -o ../myarchive.zip @
cd ..
rm -rf workrepo

あんまり自信ないんですけどスクリプトファイルに落とすとこんな感じ?

#!/usr/bin/bash

set -eu

unset workdir
onexit() {
  if [ -n ${workdir-} ]; then
    rm -rf "$workdir"
  fi
}
trap onexit EXIT

workdir=$(mktemp --tmpdir -d gitzip.XXXXXX)


cp -r "$2" "$workdir"

pushd "$workdir"
git init
git add .
git commit -m "commit for zip"
popd

git archive --format=zip -o "$1" --remote="$workdir" HEAD
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした