When clicking on our shared open repository (on top of ssh), the post commit does not work properly.
This is pretty common since I found a lot of threads here, and it works great for two other repositories on the same server, which drives me crazy.
#!/bin/sh GIT_WORK_TREE=/ab/cd/staging git checkout -f
The repository itself is located in the same directory as the directory to which the hook should be sent to
/ab/cd/barerepo
When clicked, it does not check the files for the intended path, but gives this error message:
Writing objects: 100% (3/3), 299 bytes, done. Total 3 (delta 2), reused 0 (delta 0) fatal: Could not jump back into original cwd error: hooks/post-receive exited with error code 128
I could not find any information on what this means. (Google only calls commit commit to git, if I can tell). So I read and guessed and tried ...
- Additionally set GIT_DIR in the receiver after receiving.
- reinitializing the main repo with - git -dir = / ab / cd / barerepo --working-dir = / ab / cd / staging
- manual configuration of the working directory in the barerepo / config file
- setting up an empty blank copy and commit
- setting up a bare repo by cloning
Now the configuration looks like this:
[core] repositoryformatversion = 0 filemode = true bare = true
but I also had it (effortless)
[core] repositoryformatversion = 0 filemode = true bare = true sharedrepository = 1 worktree = /ab/cd/staging logallrefupdates = true [receive] denyNonFastforwards = true
I also added a second line to the hook after taking
echo "post-receive done" > updated.txt
It writes the file to the open repository directory. This makes sense to me, as GIT_DIR seems to be set to ".", As evidenced by the post-receive message I received from another SO question
echo Running $BASH_SOURCE set | egrep GIT echo PWD is $PWD
Result:
Running hooks/post-receive GIT_DIR=. PWD is /ab/cd/barerepo
So, how can I bring git to return to the original cwd (current working directory?)? FYI: I'm still pretty new to git, and I have a dumb feeling that I'm missing something obvious, but not finding anything significant in this particular error message, makes me think. The push itself works great, by the way.