从私人Github仓库下载

时间:2016-04-27 09:03:17

标签: git bash github wget

我正在尝试减少生产服务器上项目的占用空间。我不是这种操作的专家,但我提出了以下bash脚本。

VERSION=$1
rm -rf pydata

# clone the entire github repository. This is kind of inefficient as we delete the .git folder in a moment
git clone git@github.com:tt/pydata.git

cd pydata

# checkout the correct version
git checkout $VERSION --

# Print the version into a txt file
echo $VERSION > version.txt

# Build the Python environment using conda
make build

# delete a bunch of files not needed on the server but contained in the git repository (documentation etc.)
xargs rm -rf < delete.txt
rm delete.txt

# back into the folder
cd ..

是否有一种优雅的方式来查找最新的标签(如果用户没有提供所需的标签($ 1))?

我的小研究表明,相当克隆整个git rep然后删除.git文件夹,最好有gitub可以使用gitub吗?

替代方法是在tar.gz档案中使用wget?这样可以避免下载.git文件夹,但似乎会产生各种额外的麻烦,因为它不支持开箱即用的SSH?

感谢

1 个答案:

答案 0 :(得分:1)

要获取最新的git标记,您可以使用git describe

if [ ''$VERSION = '' ]
then
  VERSION=$(git describe)
fi
相关问题