Tworzenie repozytorium git z folderu produkcyjnego
Mam komputer z produkcyjną stroną internetową, chcę utworzyć repozytorium git na tym komputerze, aby zarządzać witryną za pomocą git.
Pierwszą rzeczą, którą zrobiłem, było utworzenie pustego repozytorium .git w maszynie produkcyjnej:
mkdir repos
cd repos
mkdir production.git
cd production.git
git init --bare
W tym repozytorium pod hakami / po otrzymaniu dodałem następujące wiersze:
#!/bin/sh
GIT_WORK_TREE=/var/www/production_website git checkout -f
Następnie pobrałem folder z moją witryną produkcyjną na mój komputer lokalny i uruchomiłem git:
cd production_website
git init
Po tym dokonałem pierwszego zatwierdzenia:
git add .
git commit -m "first commit"
I w końcu dodałem zdalne repozytorium i zrobiłem pierwszy krok:
git remote add origin ssh://[email protected]/repos/production.git
git push origin master
Ale kiedy pcham, daje mi następujący komunikat o błędzie:
remote: fatal: This operation must be run in a work tree
Który jest wyzwalany, gdy hak po odbiorze jest aktywowany.
Jakieś sugestie, co mogę zrobić źle?
AKTUALIZACJA:
W pierwszym kroku, podczas tworzenia pustego repozytorium .git w maszynie produkcyjnej, jeśli używamgit init
zamiastgit init --bare
Otrzymuję ten komunikat o błędzie podczas wypychania:
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.