githexo

I can't find any file in the intended directory on my server, but 'hexo d' runs fine


I set a user called 'git' on my server, and I can connect to the server(Debian 9 x64) via 'ssh -v git@xxx.xxx.xxx.xxx'. The website's intended directory is '/home/www/hexo', and I have a correct Nginx server for that. I created a hook file:

cd ~
git init --bare hexo.git
vi ~/hexo.git/hooks/post-receive

and entered

git --work-tree=/home/www/hexo --git-dir=/home/git/hexo.git checkout -f

and authorize it

chmod +x ~/hexo.git/hooks/post-receive
cd ~
sudo chmod -R 777 /home/www/hexo

then I reboot the machine. Then I modified the _config.yml on my local machine(Win10 x64)

deploy:
type: git
repo:
  gcp: git@XXX.XXX.XXX.XXX:/home/git/hexo.git
branch: master

and the url. When I ran the command 'hexo cl && hexo g && hexo d', I got this:

$ hexo d
INFO  Validating config
INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
INFO  Copying files from extend dirs...
warning: LF will be replaced by CRLF in 2020/12/23/hello-world/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in 2020/12/23/my-first-blog/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/2020/12/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/2020/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in archives/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in css/main.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/algolia-search.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/bookmark.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/local-search.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/motion.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/next-boot.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/schemes/muse.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/schemes/pisces.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in js/utils.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in lib/anime.min.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in lib/font-awesome/css/all.min.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in lib/velocity/velocity.min.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in lib/velocity/velocity.ui.min.js.
The file will have its original line endings in your working directory
On branch master
nothing to commit, working tree clean
Everything up-to-date
Branch 'master' set up to track remote branch 'master' from 'git@34.94.20.213:/home/git/hexo.git'.
INFO  Deploy done: git

For me, it looks fine.It seems that no errors had occured. But when I tried to visit my site, I can't open it.When I visit the '/home/www/hexo', no files had shown up. I can't figuer out why.


Solution

  • Try and checkout the path:

    #!/bin/bash
    echo "Executing post-receive hook"
    unset GIT_DIR
    git --work-tree=/home/www/hexo --git-dir=/home/git/hexo.git checkout -f -- .
    

    Note the -- . at the end, that should force the files to be restored in the work-tree.