teepusink
teepusink

Reputation: 28902

Git hook - Local machine to remote server hook script

I'm on a Mac and I'm trying to create a workflow to improve my process.
So I just installed git on my own machine.
What I'm having issue now is how can I create a post-update hook to push changes I made locally to my remote server?
Note: the git server is on my local machine, so it is not accessible from the hosting server
There are a lot of different hooks, is post-update hook even the right hook I should be doing this on?

This is what I have so far, but it is creating an error right now.

# trying to get a list of files that I just pushed to my local git server, but it is failing because apparently 'diff-index' isn't available on the server side of git
files_modified=`git diff-index --name-only HEAD`

for f in $files_modified; do
  # trying to print out the files.
  # the goal here is I'm trying to execute 'scp' to push the files to the server, but please let me know if there is a better solution
  echo f
done

exit

Thank you,
Tee

Upvotes: 0

Views: 110

Answers (1)

jthill
jthill

Reputation: 60443

Repositories set up to auto-forward pushes can use post-update. I'd be extremely leery of a repo that initiates pushes on its own, because at least rebase and reset do a Jekyll-and-Hyde number on pushed refs, turning from very useful operations into fraught and fragile ones.

Upvotes: 1

Related Questions