Force remote to checkout branch
We currently deploy to a dev server via Git with a post-receive hook. It is a dev server rather than a staging server so we would like to be able to deploy/view multiple branches (rather than just a "dev" branch or somethng similar).
When a new branch or commit is pushed the post-receive hook successfully performs a checkout on the remote repo to whatever branch is pushed.
Our typical cycle might be:
View new branch1 on dev server - git push devserver branch1
View new branch2 on dev server - git push devserver branch2
View old branch1 on dev server again - git push devserver branch1
However when we would like to checkout to an branch older branch than the current active one we cannot do git push devserver branch1 because the remote repo responds with "Everything up-to-date" since branch1 has already been pushed a while ago. Obviously the post-receive hook is not run so is there another way to action the remote checkout?
I know I can SSH into the dev server and checkout to the branch1 that way but I would like to perform the action from my local repo if possible. I have tried the pre-receive and update hooks but neither of those seem to run in this circumstances.
Any help much appreciated!
Since it is just a (dev) server, why don't you delete the branch and recreate it?
git push devserver :branch1 git push devserver branch1