bry*_*edy 11 git gzip pipe tar backup-strategies
我正在尝试为我的远程托管的git repos制作一个简单的备份脚本.在脚本中我有几行目前看起来像这样:
git clone git@server:repo.git $DEST
tar czvf repo.tgz $DEST
rm -rf $DEST
Run Code Online (Sandbox Code Playgroud)
有没有办法让这一切都发生在一条线上?我可以将git clone传递给tar命令吗?我不需要克隆目录,我只想要它的压缩存档.
我尝试了一些实验,但似乎无法弄清楚语法.
man*_*lds 13
不,你不能只是管道,git clone因为它没有写出标准输出.为什么你需要单线?他们非常适合吹嘘你可以在一行中做一些很酷的事情,但在现实世界中却不是很理想.
你可以做类似下面的事情,但你不会像以下.git那样git clone:
git archive --format=tar --remote=git@server:repo.git master | tar -xf -
Run Code Online (Sandbox Code Playgroud)
从git archive手册
--remote=<repo>
Instead of making a tar archive from the local repository, retrieve a tar archive from a remote repository.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12815 次 |
| 最近记录: |