0

I'm working with html & css files locally. After I git push the files to my server (into a bare directory which I created with mkdir bare_repos/mysite && cd bare_repos/mysite && git init --bare), I don't want to have to ssh into the server, go into my ~/public_html/mysite directory and type git pull. I think a hook should do this but I'm not sure how?

The files in my bare_repos/mysite/hooks/ directory are: applypatch-msg.sample, post-update.sample, pre-commit.sample, pre-rebase.sample, prepare-commit-msg.sample, commit-msg.sample, pre-applypatch.sample, pre-push.sample, pre-receive.sample, update.sample

Which file should I edit and what should be added to it? I want to be able to push from my local machine and then simply see the changes on website from my browser (no ssh'ing needed)

2 Answers 2

1

You need update or post-receive hook enabled in your bare repository. Search for some examples: post-receive, update.

The hooks must be named exactly update or post-receive (not update.sample or post-receive.sh, for example). They also must be executable.

Sign up to request clarification or add additional context in comments.

Comments

1

I followed instructions here. I created a post-receive file and added:

#!/bin/sh
GIT_WORK_TREE=/home/username/public_html/mysite git checkout -f

Then I made it executable (chmod +x post-receive)

Now when I git push, changes are automatically seen on my website.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.