微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

接收后挂钩导致生产文件夹中的文件未跟踪

如何解决接收后挂钩导致生产文件夹中的文件未跟踪

我在Google上检查了类似的问题,发现与该问题类似的唯一问题是此主题Post-receive script results in untracked/modified files

情况是这样。我从4.4 Git on the Server - Setting Up the Server教程中获得指导。

在计算机1上进行裸仓库:

$ cd /srv/git
$ mkdir project.git
$ cd project.git
$ git init --bare
Initialized empty Git repository in /srv/git/project.git/

将第一个版本推送到计算机2上的裸仓库中

# on John's computer
$ cd myproject
$ git init
$ git add .
$ git commit -m 'Initial commit'
$ git remote add origin git@gitserver:/srv/git/project.git
$ git push origin master

克隆计算机1上的生产文件

git clone git@gitserver:/srv/git/project.git
$ cd project
$ vim README
$ git commit -am 'Fix for README file'
$ git push origin master

两台机器上的推/拉看上去都很不错。

现在在挂钩文件夹中制作后接收挂钩:

#!/bin/bash
while read oldrev newrev ref
do
    if [[ $ref =~ .*/master$ ]];
    then
        echo "Master ref received.  deploying master branch to production..."
        git --work-tree=/var/www/html/project --git-dir=/srv/git/project.git checkout -f
    else
        echo "Ref $ref successfully received.  Doing nothing: only the master branch may be deployed on this server."
    fi
done

好。当我提交2个文件“ test_file1”和“ test_file2”到裸机时,从计算机2推送。成功。 浏览以查看该钩子是否在计算机1上的生产文件夹中工作。确定存在“ test_file1”和“ test_file2”文件

get status 

在生产文件夹中呼应:

On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        public/test_file1
        public/test_file2

nothing added to commit but untracked files present (use "git add" to track)

我在生产文件夹和本地(测试)文件夹中都有.git文件夹。 知道这是否正常吗?以及如何解决

解决方法

您通常在.git文件夹中没有production文件夹:只有裸仓库中的post-receive钩子才允许修改(checkout -f)说{{1 }}文件夹。

production文件夹不应了解有关Git的任何信息(除非Git是实际运行存储在“生产”中的程序/项目的基本元素)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。