I'm trying to setup a push to deploy process over my home network. I'm trying to have a setup where I can run a process (I'll put into a bash script in time) on the server that will setup the empty repository there. Then, from my development device, I'll push to that repo on the server.
I'm working from a slightly modified version of the following tutorial. The tutorial seems to assume that the project is currently sitting on the server. I want to create the project in my development environment then have the server setup where I can then push the project to the server.
http://danbarber.me/using-git-for-deployment/
1) Here is my process I follow to setup the live repo and the bare repo on the server:
# create our app space and initialise git
mkdir /var/www/myproject && cd /var/www/myproject
git init
touch README.md
git add .
git commit -m "Setup new project"
# create bare repository
mkdir -p /var/git/myproject.git
cd /var/git/myproject.git
git init --bare
cd /var/www/myproject
git push /var/git/myproject.git master # error here too "error: src refspec master does not match any."
# configure /var/www/myproject/.git/config
cd /var/www/myproject/
git remote add hub /var/git/myproject.git
# create hook to make sure that any time anything is pushed to the hub repository it will be pulled into the live repo
# write this to /var/git/myproject.git/hooks/post-update
#!/bin/sh
echo
echo "**** Pulling changes into Live [Hub's post-update hook]"
echo
cd /var/www/myproject || exit
unset GIT_DIR
git pull hub master
exec git-update-server-info
^D
# make sure the file is executable
chmod +x /var/git/myproject.git/hooks/post-update
# create hook to make sure that any ‘in place’ changes we make to the web code is pushed to the hub when committed
# **write this to /var/www/myproject/.git/hooks/post-commit
#!/bin/sh
echo
echo "**** pushing changes to Hub [Live's post-commit hook]"
echo
git push hub
^D
# Again, ensure this file is executable.
chmod +x /var/www/myproject/.git/hooks/post-commit
2) The on my development device I do the following:
rails new myproject
cd myproject
git init
git remote add origin martyn@192.168.0.100:/var/git/myproject.git
git push origin master
..but I get the following error:
error: src refspec master does not match any.
error: failed to push some refs to 'martyn@192.168.0.100:/var/git/myproject.git'
..does anyone know what I need to do. Following the tutorial it assumes that the app already exists on the server, so it's slightly different in that it doesn't create an empty repo. But I don't want to FTP the apps files over, clone it from there then create a repo on the server. I want to create the app in development environment, run a script on the server to setup git there, then push the app from dev to my server.
Anyway this is my first time to try this, I'd appreciate any pointers or if anyone has a better suggestion to what I should be doing. Thanks
UPDATE:
I added touch README.md
so that there is something to commit. Also, I added the code to setup an empty rails project and create the local repo. I get no errors on the server. But I still can't do what I want to do on my development device. When I do the following though:
cd /var/www/myproject
git clone martyn@192.168.0.100:/var/git/myproject.git myproject
I can clone down the repo from the server, then add files etc .. then push. But it's not how I want to create a new project. I want to first start building the app locally, create a local repo, .. then shortly after when I'm ready to commit, setup the server and PUSH files. Similar process to Heroku or Github, with those you don't have to clone an empty repo first from there before you can push. You can just push the files to there once their server is setup. This is similar to what I'm trying to do.