gitgit-bare

How to get changed files in my repository created with --bare


Hello I have a repository created with --bare on my git server, I would like for example in the master branch when I had change of my several codes.js I would take the modified file and execute it by a routine that I have in nodejs, but in the repository that I created with --bare I do not see the files so my routine will get the modified ones. could anyone help me how I could do this.

summary: if I have for example three codes.js and two are modified today, I would like my routine nodejs to ask git for the modified files to take them in their modification and execute the script.


Solution

  • to access the files of my repository create with --bare first: I created a file called post-receive inside the hooks directory, then run the nano hooks / post-receive command.

    containing the following information:

    #! / bin / bash
    GIT_WORK_TREE = / www / myfiles checkout -f
    

      execute permission for the hook we created, so we do this using the command:

    sudo chmod + x hook / post-receive.
    

    Summarizing how it occurs and the role of hook post-receive, post-receive executes as an observer spec and acts whenever a new post is received in the app.git directory, so whenever you run the git push deploy master command, the post -receive will get the files and send to the directory indicated in GIT_WORK_TREE and check this guy as current version to work, it is worth remembering that a bare-type repository does not save the versions.