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...
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With