I need to git push to remote, and that push need to be current working copy. Because, pushed source is a web host. So, pushed files need to be currently in use. I am sure no one will edit files at the host 🙂
This question is follow up of these 2 questions,
Is it possible to have a git repo inside another git repo and what difference does –bare switch make when initing a git repo?
Edit: bare repo is not what I want, since files need to be directly used on remote machine, and need to be found on the locations where I put them.
Edit2: It is my understanding that bare repo doesn’t keep the file hieararchy, and keep repo data in root directory
Here is a step-by-step on how to create a git repo on your web host that will allow direct pushes, set it up as a remote for your local repo, and push changes to it. Note that you need to have ssh access to your web host, and have git installed.
On your web host (ssh’d in):
Now with your local repo (run these git commands inside the repo):
Now, your changes have been pushed to the checked-out repo on the web host. However, they will not be reflected in the working dir (that is, your changes will not take effect immediately). This is because you have pushed directly to the active branch. To finish up, you need to either
git checkout -fto update the working dirgit post-receivehook to do it automatically.To have instant, automatic deployment with a
post-receivehook check out this git site deployment howto.