Answer the question
In order to leave comments, you need to log in
Crunchy automation in production: git add doesn't work in pre-receive hook
There is a git repository ( not bare ) on production, the task is to maximize the automation of source synchronization on developers' machines with production.
As part of the task, I developed a solution:
pre-receive
add changes from the working copy on the production server to the repository and commit, because SEO specialists and other departments also have access to upload and delete their filespost-receive
forcibly upload the contents of the repository to production, usinggit-checkout -f
git add .
, the command gives an error adding a file.git/COMMIT_EDITMSG
error: unable to add .git/COMMIT_EDITMSG to index
fatal: adding files failed
Why git
it is trying to add files from its directory remains a mystery to me ... git status
, processing the corresponding changes with git add
and git rm
, but it seems to me that the problem is somewhere higher and on the surface and I don't have enough experience. pre-receive
:#!/bin/sh
#### указываем рабочие папки
export GIT_WORK_TREE=/workingpath
export GIT_DIR=/workingpath/.git
#### добавляем новые изменения
git add .
#### обновляем модификации
git add -u .
#### фиксируем
git commit -a -m 'Sync on remote PUSH'
#### на время тестирования фэйлим все коммиты
exit 1
git version 1.5.6.5
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question