Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git basic setup

Tags:

git

I have (finally) convinced my manager to allow us to set up version control, and have been doing some research for the past few days and have decided on git. Anyways I found a tutorial here http://toroid.org/ams/git-website-howto on a basic setup, that will push changes to remote repository. This would work great for our company.

Here are the steps I went through

Local box

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 Box

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

Now where i do the push I get the error "This operation must be run in a work tree" This is coming from the post-receive hook. I know I am missing a step but just not sure what exactly that is...

like image 387
Kris Avatar asked Dec 14 '11 21:12

Kris


1 Answers

I suppose your working directory website is empty. Hence, your git add . does not add anything, and the next commit does not create a new commit.

In order to generate the master branch, you need to complete at least one commit, with at least one file.

In the local box, do

touch empty
git add empty
git commit -m "Initial commit into git"
git push web
like image 86
Arialdo Martini Avatar answered Oct 29 '22 17:10

Arialdo Martini