Git: how to do remote directory update on click?

I want to use git to manage some data on a remote server, so I created a non-bare repository there. I can click on it without problems, and the repository itself is updated, but the actual files are not changed / not added / deleted. I have to send ssh to the server and do

git reset --hard HEAD 

to actually update the file structure.

What to do?

+7
git version-control git-push
source share
4 answers

You must not do this. He recommended having open storage. In other words, the files were not extracted, only the .git directory itself. Then you can check the repository for some other place on your server - let's say your web root. So you get:

  • git best practice. According to the Git docs, you may get "unexpected results" if you don't execute it. Anyone who is well versed in programming knows that "unexpected results" are code for "probably eat your children and should be avoided at all costs."

  • improved security if you plan to have scanned files on the server accessible from the web server.

  • Local changes in your extracted code, as well as the ability to quickly make changes to the verification code. You might try to do this directly in the repository, but that would be dirty and more error prone.

  • Ability to update your server repository regardless of updating your existing service code. This is very important if you work remotely and need to send something to the server and then do further work before it is ready for your live service, or if you have changes in your real service code (say, different configuration settings ) and it is necessary to combine these changes with changes in the repo, but cannot do this only now.

I would recommend the following steps:

  • Follow Git's instructions for setting up a bare repository
  • Check the code from your repo to your dir service destination
  • Setting up a Git binding (post-commit should be suitable for IIRC) to update your live service when updating the repository. It should probably be connected to the live dir service and make Git pull --rebase and possibly set some file permissions.
  • Just release your repo code from your developer window.
+7
source share

Use the hook after the update:

hooks

There you can do whatever you want with every update.

+3
source share

This, fortunately, is now directly supported in git! You can find the details in this answer that I just supported:

stack overflow

He recommends setting up the remote with

 git config receive.denyCurrentBranch updateInstead 

so clicking leads to an updated working copy!

+3
source share

Git Version 1.9.1
Ubuntu 14.04 LTS Server
LAMP server

I installed my LAMP server to update my working directory of my Git repository when one of my web developers clicks on the change server. I noticed that the log will notice new commits, but will not update the working directory. Instead manually (git check -f) for each update, it can be set automatically to do this after receiving a click.

  • In your ".git" directory, go to the "hooks" folder.
  • Create a file called "post-receive" in the "hooks" folder with this content:

    #! / Bin / w

    # Updating the working directory after receiving push from remote clients.
    # This should be directed to the Git working directory.

    GIT_WORK_TREE = / var / www / dev_site Git checkout -f

  • Enable permissions to execute the file by typing "chmod + x post-receive" into the "hooks" folder.

Now it will update the working directory when commits are moved to the Git repository. My site now shows changes when I visit it in a browser.

My working directory is / var / www / dev_site

+1
source share

All Articles