0

i suffered a very bad problem. i want push local repository to remote repository from my client and then excute post-receive script copy to webroot.there is a piece of code in my post-receive as follows:

cd /home/james/mywebsite
git init
git pull ssh://git@git.xxx.com/repository/xxx.git
cp ./* /usr/local/apache2/htdocs/mywebsite/
...

but the problem is that git init command create a bare repository which files in .git now is all in /home/james/mywebsite derectory.this caused i cannot use git pull command.but i'm not use git init --bare.why create a bare repository?

tisp: 1 mysql git version is 1.7.1. 2 i use git user created my repository and it is located at /repository/xxx.git. please help me...dear all

  • Was `/home/james/mywebsite` already a git repository before? If yes, does its local config say `core.bare = true`? – ElpieKay Jun 10 '17 at 12:45
  • thanks. /home/james/mywebsite is not a git repository before.when create the reporsitoy in /home/james/mywebsite, i enter /home/james/mywebsite and find the config is "core.bare = true .......and others configs". so i use "git config --global core.bare false". but it still not works. – user8141150 Jun 10 '17 at 13:18
  • Try `git config core.bare false` in `/home/james/mywebsite`. `--global` is for the global settings which will be overridden by the local settings. – ElpieKay Jun 10 '17 at 13:22
  • but before git init, the derectory is not a reporsitory derectory...so cannot use git config ..... – user8141150 Jun 10 '17 at 14:35
  • Running `git init` (without options) does *not* create a bare repository (not even in very old versions of Git such as 1.7.1). Something else is wrong, something you have not shown here. In any case running `git init` in a *post-receive* script is not a good idea. Note that all Git hooks generally run with an environment variable, `GIT_DIR`, set, usually to `.` or `.git`. (In fact, that may be the immediate problem: your script may have created a non-bare clone with the Git directory in `.` instead of `.git`. But there will be more problems later, running `git init` in a post-receive script.) – torek Jun 10 '17 at 16:56
  • in fact, 'git init...'commans are not running in a post-receive script.In order to express my question clearly,i just write 'git init...'commands in post-receive script.actually,it is running a shell.like this: sh /home/james/update.sh,and the commands like 'git init' is in the shell.even though it still has problems.you said the GIT_DIR,i write 'pwd' in post-receive or my shell, it is a write derectory. – user8141150 Jun 11 '17 at 05:45

0 Answers0