Я установил пользователя с именем «git» на своем сервере и могу подключиться к серверу (Debian 9 x64) через «ssh -v [email protected]». Предполагаемый каталог веб-сайта — «/home/www/hexo», и у меня есть правильный сервер Nginx для этого. Я создал файл ловушки:
cd ~
git init --bare hexo.git
vi ~/hexo.git/hooks/post-receive
и вошел
git --work-tree=/home/www/hexo --git-dir=/home/git/hexo.git checkout -f
и авторизовать его
chmod +x ~/hexo.git/hooks/post-receive
cd ~
sudo chmod -R 777 /home/www/hexo
затем я перезагружаю машину. Затем я изменил _config.yml на своей локальной машине (Win10 x64).
deploy:
type: git
repo:
gcp: [email protected]:/home/git/hexo.git
branch: master
и URL. Когда я запустил команду «hexo cl && hexo g && hexo d», я получил это:
$ 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 '[email protected]:/home/git/hexo.git'.
INFO Deploy done: git
Для меня это выглядит нормально. Вроде бы ошибок не было. Но когда я попытался зайти на свой сайт, я не могу его открыть. Когда я захожу в «/home/www/hexo», никаких файлов не появляется. Я не могу понять, почему.
Попробуйте проверить путь:
#!/bin/bash
echo "Executing post-receive hook"
unset GIT_DIR
git --work-tree=/home/www/hexo --git-dir=/home/git/hexo.git checkout -f -- .
Обратите внимание на -- .
в конце, это должно привести к восстановлению файлов в рабочем дереве.