0

I'm brand new to Git and I was following this tutorial to set up a Git workflow on my local machine and remotely. I am the sole developer on this project.

The project uses the Laravel PHP framework. I want the application files outside of the public folder and the public files within a directory under a public_html folder that was viewable on the web. My local files are setup like this:

grapejuice/ (repository top)
    grapejuice/ (app files)
    public_html/
        grapejuice/ (public files)

On my hosting service, I have other websites as well listed under the public_html directory, so I needed a to separate this projects' folders from the other websites, hence the subdirectory under public_html.

I'm getting hung up on when I try to reflect my push changes to the working files on the remote server. I'm following the above tutorial and created a post-receive hook. My hook looks like this:

#!/bin/bash
git --work-tree=/home3/ambuoyan --git-dir=/home3/ambuoyan/grapejuice.git checkout -f

However, when I run commit and push to the bare remote repository, I get a list of the git remote usage options and this message:

remote: hooks/post-receive: line 3: --git-dir=/home3/ambuoyan/grapejuice.git: No such file or directory
To ssh://username@website.com/home3/ambuoyan/grapejuice.git
   f94473c..42ce6aa  master -> master

So I'm confused. The directory does exist, I know it does. Did the command partially work or not at all? When I try to push again, it says there are no changes so I think at least the bare repository is up to date, but none of my working files are being reflected remotely.

  • The push did work. Obviously there was some issue with the post-receive hook though. Particularly interesting is that you got an error message that said `line 3: ...` when there *is no line 3* in your source example (and even if there were, Git itself would have no knowledge of the line number). (And—not related but also curious—putting the bare repo underneath the work-tree, rather than in parallel to it, seems like a weird thing to do.) – torek Jul 28 '16 at 10:08
  • Wow! you're right, there shouldn't have been line 3...so I checked and sure enough, for whatever reason, the file split the 2nd line into 3. The only thing I can think of is that I put in 2 spaces between the `work-tree` and `git-dir` options, but would nano automatically just split that into 2 separate lines? Anyway, I tried the push again and this time, the post-receive hook worked! I also doubled checked the file this time and it was only 2 lines for sure! Thanks! And about, the bare repo being underneath the work-tree...I wasn't too sure about it either, I might move it up. Thanks! – dapperdanman1400 Jul 28 '16 at 13:03
  • Don't know about nano, I use vi/vim myself (and ed/sed, and I have a private version of Emacs but have not used it for 10+ years now). As for the other thing, it probably should work to have the bare repo under the work-dir, it just seems odd. – torek Jul 28 '16 at 16:25

0 Answers0