From: Stephen Major <smajor@gmail.com>
To: git@vger.kernel.org
Subject: Re: post-receive for web deployment
Date: Sun, 18 Dec 2011 18:42:56 -0800 [thread overview]
Message-ID: <CALzTOm+sJHF_7WzjD7bCqAiAbQSV0A3hEX1KdWfFzV7-ePzX2w@mail.gmail.com> (raw)
In-Reply-To: <CALzTOmJUqzO8H5UxyFaodi98DBJtFvsbQsHsYh1U=Ggq3NRO5A@mail.gmail.com>
Hello,
I am having some difficulty understanding what I am doing wrong when
working with git to deploy a website through the use of a post-receive
hook on the remote.
Here is the script:
#!/bin/sh
staging_path="/home/user/domains/domain.com/public_html/staging"
live_path="/home/user/domains/domain.com/public_html/live"
while read oldrev newrev ref
do
branch=$(echo $ref | cut -d/ -f3)
# ***
# update the live site
#
if [[ "master" == "$branch" ]]; then
export GIT_WORK_TREE=$live_path
git checkout -f $branch
echo "Release has been pushed to production"
# ***
# we update the staging server with the latest push
#
elif [[ "develop" == "$branch" ]]; then
echo "Resetting staging tree"
export GIT_WORK_TREE=$staging_path
git checkout -f $branch
echo "Develop has been pushed to staging"
fi
done
This is what we have done:
git checkout develop
touch 1 2 3 4 5 6
git add .
git commit -am "added some files"
git push origin develop
checking the remote server now all files are found in:
/home/user/domains/domain.com/public_html/staging
git checkout master
git merge develop
git push origin master
checking the remote server now all files are found in:
/home/user/domains/domain.com/public_html/live
git checkout develop
git rm 4 5 6
git commit -am "removed some files"
git push origin develop
checking the remote server now files 4 5 6 have been removed from:
/home/user/domains/domain.com/public_html/staging
git checkout master
git merge develop
git push origin master
checking the remote server files 4 5 6 are still found in:
/home/user/domains/domain.com/public_html/live
Why is this happening? checking the local repo for master shows the
files are removed there... pulling the latest from origin:master shows
the files have been removed... but why were they not removed from the
working tree like they were on the staging working tree?
well I think it has something to do with later commits and therefor
the working tree of the live server could quickly become out of sync
with the development tree
a quick test, lets checkout master again and perform the removes
directly on it then push it back:
git checkout master
git rm 1 2 3
git commit -am "removed 1 2 3"
git push origin master
checking the remote server now files 1 2 3 have been removed from:
/home/user/domains/domain.com/public_html/live
Okay weird so they remove when the commit happens directly on that
branch and is pushed to the remote but they dont get removed if the
removal happened on a different branch and is merged in then pushed to
the remote....
anyone have an explanation or a workaround?
next parent reply other threads:[~2011-12-19 2:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CALzTOmJUqzO8H5UxyFaodi98DBJtFvsbQsHsYh1U=Ggq3NRO5A@mail.gmail.com>
2011-12-19 2:42 ` Stephen Major [this message]
2011-12-19 6:55 ` post-receive for web deployment Johannes Sixt
2011-12-19 10:35 ` Sitaram Chamarty
2011-12-19 12:42 ` Stephen Major
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALzTOm+sJHF_7WzjD7bCqAiAbQSV0A3hEX1KdWfFzV7-ePzX2w@mail.gmail.com \
--to=smajor@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.