git archive 命令使用
公司项目中的一个使用场景
背景
在公司项目中看到的一个使用场景
现场
# 原始
git archive --remote=git@git.saybot.net:ACE/courseware/pptWebPlayer.git master:KeynoteDHTMLPlayer | tar -xv -C assets/public/subapp/pptWebPlayer
# > /dev/null 2>&1 选项来禁止 git archive 显示任何信息(chatgpt 提到的 -q,其实并不存在)
git archive --remote=git@git.saybot.net:ACE/courseware/pptWebPlayer.git master:KeynoteDHTMLPlayer | tar -x -C assets/public/subapp/pptWebPlayer > /dev/null 2>&1
# 类比
cd ~/Downloads
mkdir -p test/dist
git archive --remote=git@git.saybot.net:ACE/kellis/kellis-ng-front.git master:bin | tar -xv -C test/dist
git archive --remote=git@github.com:afeiship/next.git main:dist | tar -xv -C test/dist
报错
翻阅资料,
github
并不支持这个操作。
在 github 的项目使用此命令会有如下提示:
✦ $ git archive --remote=git@github.com:afeiship/next.git main:dist | tar -xv -C test/dist
Invalid command: git-upload-archive 'afeiship/next.git'
You appear to be using ssh to clone a git:// URL.
Make sure your core.gitProxy config option and the
GIT_PROXY_COMMAND environment variable are NOT set.
fatal: the remote end hung up unexpectedly
更新命令如下
依然不行。
$ git archive --remote=https://github.com/afeiship/next.git main:dist | tar -xv -C test/dist
> fatal: operation not supported by protocol