Git basic setup

I (finally) convinced my manager to let us establish version control and spent several years doing some research and decided on git. In any case, I found the tutorial here http://toroid.org/ams/git-website-howto on the basic setup, which will lead to changes in the remote repository. This is perfect for our company.

Here are the steps that I went through

Local block

cd /website git init git add . git commit -m "Initial commit into git" 

server

 cd /var/git/ mkdir website.git cd website.git git init --bare mkdir /var/www/website cat > hooks/post-receive #!/bin/sh GIT_WORK_TREE=/var/www/website git checkout -f 

chmod + x hooks / post-receive

Local block

 git remote add web ssh:// user@server /var/git/website.git git push web +master:refs/heads/master 

Now, when I do a push, I get the error message "This operation should be performed in the work tree." This comes from the post-receive hook. I know that I am missing a step, but I just don’t know what it is ...

+6
source share
1 answer

I believe your working directory website empty. Hence your git add . adds nothing, and the next commit does not create a new commit.

To generate the main branch, you need to execute at least one commit with at least one file.

In the local field do

 touch empty git add empty git commit -m "Initial commit into git" git push web 
+2
source

Source: https://habr.com/ru/post/903803/


All Articles