git github发布到网站,但不删除文件夹?

时间:2012-10-25 19:12:01

标签: git bash github

我从Github到我们网站的网站服务器。所有操作都是通过bash脚本和scalr完成的。在我们的网站中,其中一个文件夹是到S3文件夹的NFS安装。有没有办法,我可以做一个拉,而不杀死该文件夹,并不得不重新安装它? 这是我目前的剧本:

## Git Clone -------------------------------------------------------------------

if [ -d "$DEPLOY_PATH"/.git ]; then
    cd "$DEPLOY_PATH"
    if $GIT_PATH status >/dev/null 2>&1; then
       $GIT_PATH pull
       exit 0
    fi
fi

$GIT_PATH clone $GIT_REPO_URL $GIT_CL_DIR  .

## Git Checkout ----------------------------------------------------------------
# There should be *no* changes to the pristine repo.
echo "Ensure pristine copy. Executing 'git reset --hard'."
$GIT_PATH reset --hard HEAD 2>/dev/null

echo "Pulling updates from $GIT_REMOTE"
$GIT_PATH fetch $GIT_REMOTE

current_branch=$($GIT_PATH branch | awk '/\* /{print $2}')

if [[ "$current_branch" = "$GIT_BRANCH" ]] then
    echo "Already on branch '$GIT_BRANCH'."
elif ! $GIT_PATH branch | awk "/$GIT_BRANCH$/" >/dev/null 2>&1 then
    echo "Checkout of branch '$GIT_BRANCH'"
    $GIT_PATH checkout -b $GIT_BRANCH --track $GIT_REMOTE/$GIT_BRANCH 2>/dev/null

elif ! $GIT_PATH checkout $GIT_BRANCH 2>/dev/null then
    echo "Branch '$GIT_REMOTE/$GIT_BRANCH' not found. Skipping remainder of update." 1>&2
    exit 1
fi

# Run our git commands
$GIT_PATH pull

## Get submodules, if exist.
if [ -e ".gitmodules" ]
then
    echo "Updating submodules."
    $GIT_PATH submodule init 2>/dev/null
    $GIT_PATH submodule update
fi

然后我安装文件夹......等等。

1 个答案:

答案 0 :(得分:1)

一种方法是将符号链接到已安装的目录 即使该符号链接位于git工作树中,它也不会受到Git的影响,因为它不遵循符号链接(详见“Getting git to follow symlinks (again)”)