Tuesday, November 24, 2015 [Tweets] [Favorites]

Pushing to the Git Working Copy on a Web Server

Rachel Worthington:

With this in mind, the model that I thought would be best for me, would be a git repository on the server, and a git repository on my laptop where I like to write. I could then make changes locally, commit them, and push them to the server repository, where they would magically appear, so that hugo could run over them and re-generate my website.

Rachel Worthington:

My mysterious error also suggested a setting could be used to override this safe-guard, (the recieve.denyCurrentBranch setting) and indeed it can.

[…]

The initial error, about updating the current branch of a working copy is denied because it will make the index and and There is a way to make the setup I wanted, and I was most of the way there. The rest of the way would have involved setting up a post-recieve hook to run git reset --hard on the repository after the push. This would have kept the working copy win sync with the rest of the repository, allowing the working copy to update, whenever an external push happened.

It looks like there is also a newer way:

git config receive.denyCurrentBranch=updateInstead

[…]

Update the working tree accordingly, but refuse to do so if there are any uncommitted changes.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment