1

I'm committing changes to my local git repo, then I push the changes to the location I cloned my local repository from in the first place. Is it possible to tell the remote repository to check out HEAD locally (i.e., on the server) after the push?

Background: I'm working on assignments from university. Me and my buddy work and commit locally and then push the changes to repository on the uni - server. There, everything has to be checked out again. Git is just for the comfortability of the students, the result must always be on the server as simple files. Now, I always have to login on that server and do the checkout myself, which is really annoying because I might as well just copy the files. I know I could just make a simple bash script to do that, I'm just wondering if git could do that for me?

4 Answers 4

2

I think you need the post-receive or post-update hook.

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

Comments

1

Not out of the box, but you can use a hook to do it:

http://debuggable.com/posts/git-tip-auto-update-working-tree-via-post-receive-hook:49551efe-6414-4e86-aec6-544f4834cda3

5 Comments

Ok, I tried that, but still get: fatal: Not a git repository: '.' error: hooks/post-receive exited with error code 128 I executed "env -i git reset --hard" on the command line and added the line to the post-receive hook, but nevertheless it does not work. Any ideas?
Put a 'pwd' into the hook to see what directory it's running against, and then given that you can likely put a 'cd' command in the hook to ensure that you're in the correct place
I'm in the correct place, but the error is there nevertheless. If I simply execute git commands in the directory I am after the cd, it works just fine. Could it be that "env -i git reset --hard" does not work? I'm on a uni-server after all (although there is no error when I execute this)
If 'pwd' is returning a valid directory to a git repository but the git command is failing then I'm at a loss. Just to confirm you're not using a bare repository, right? Another option might be to use the 'work-tree' cmd line option : linux.die.net/man/1/git
I don't think so. I just used git init to create the repository.
1

You can use a git hook (post-receive would that be in your case) which executes a bash script.

Comments

1

Here is a nice walk through on how to do what you are asking

http://toroid.org/ams/git-website-howto

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.