views:

61

answers:

1

I'm attempting to create a set of git repositories and web folders in a server using the post-update hook. It would be something like:

//server/dev (for dev files) and //server/web (the apache main path)

The post-update hook for the //server/dev git repositories:

#!/bin/sh

unset GIT_DIR
PROJECT=`basename $(pwd)`
cd ../../web/${PROJECT}

echo "Updating `pwd`..."
git reset --hard

I see the update message while pushing stuff, but the //server/web folder just won't update. It keeps showing the first commit HEAD.

"HEAD is now at XXXXXXX First Commit"

There's some solutions around, but I can't seem to get it to work properly.

+1  A: 

If the repository is at some point at the last commit, then updates are made, and you pull, the pull should always be a fast-forward, which by definition cannot cause merge conflicts. The only case in which it's not is when you push a non-fast-forward update into your central repository, which you generally should not do.

Of course, you might as well plan for the worst, and make absolutely sure that this will work, even with non-fast-forward updates, so you could do:

git fetch
git reset --hard origin/master
Jefromi