1

I am pulling from Github to our webserver for our site. All actions are done via bash scripts and scalr. In our website, one of the folders is a NFS mount to a S3 folder. Is there a way I can do a pull without killing that folder and having to remount it? This is my current script:

## 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

Then I do the mounting of folders and such....

John Hamman
  • 341
  • 5
  • 16
  • 3
    Can you elaborate on why you need to unmount the folder currently to be able to pull? I.e. I don't see a direct relation between the two. Also, what are the errors with your script? – favoretti Oct 25 '12 at 19:56
  • No errors with the script, just put it for a reference to what I am doing. The folder i need to mount is a folder inside the website for uploads. Since I don't want those uploads affected by the version from Git, I need to find a way to keep git from overwriting those files. – John Hamman Oct 25 '12 at 22:35

1 Answers1

1

One way would be to symlink to the directory which is mounted.
Even if that symlink resides with a git working tree, it wouldn't be affected by Git, since it doesn't follow symlinks (as detailed in 'Getting git to follow symlinks (again)')

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250