echo "Getting ${REPO}..."
if [ -e /usr/src/app/.git ]; then
pushd /usr/src/app
git fetch
popd
else
git clone ${REPO} /usr/src/app
fi
cd /usr/src/app
echo "Switching to branch/tag ${BRANCH}..."
git checkout ${BRANCH}
Basically says, if there's no '.git' folder clone the git repo. If there is a '.git' folder fetch the data. NOTE: fetch does not change any files in the current folder, it only grabs the latest blobs and puts them inside the .git folder
The script then checks out the branch. All that does it is switch to the branch in its current state on the machine
Did you mean to update to the latest? The git fetch should be git pull origin ${BRANCH}
either that or add a
git reset --hard origin/${BRANCH}
after the git checkout
Otherwise there's not much point to the git fetch. I won't effect anything.
you also might want it to be
git reset --hard origin/${BRANCH}
git clean -d -f
That will delete any directories and files that git doesn't know about, basically making sure the current folder is exactly the state it should be after checking out. (of course maybe the app wrote stuff should stick around?)
Maybe this is intended but this code
Basically says, if there's no '.git' folder clone the git repo. If there is a '.git' folder fetch the data. NOTE: fetch does not change any files in the current folder, it only grabs the latest blobs and puts them inside the .git folder
The script then checks out the branch. All that does it is switch to the branch in its current state on the machine
Did you mean to update to the latest? The
git fetch
should begit pull origin ${BRANCH}
either that or add a
after the git checkout
Otherwise there's not much point to the
git fetch
. I won't effect anything.you also might want it to be
That will delete any directories and files that git doesn't know about, basically making sure the current folder is exactly the state it should be after checking out. (of course maybe the app wrote stuff should stick around?)