I figured out a solution, but I feel there must be a simpler way of deployment, using Git. The solution is that
- develop app with Git locally
- set up Git server
- clone the local repository locally as a bare repository
- copy the bare repository to the remote server
- set the bare repository as a remote repository
- clone a repository from the bare repository to the server (so as to have a repo with working directory)
- update the bare repository by pushing the locally committed changes.
- update working directory by pulling changes from the bare repo
It is not a simple solution, there may be better ways to use Git for deployment. I tried to use the bare repository alone on the server, and set the work-tree variable in the git config file to an other directory, but it didn't work: after the first checkout, when I updated the bare repo and tried to check out the changes, it seemed that everything ok but nothing happened in the working directory. Then I decided to clone the bare repository, so the cloned repo has a working directory, and it can be updated by a git pull (this pull the changes from the bare repo as its origin remote repository).
The big advantage of this solution is that you can fix the code on the server too, commit these changes, update the bare repo, and then you can simply update the local repository. Another advantage is that you can clone the project from the bare repo, and more participants can take part in the development if they have access to the server.
Do you know a simpler way that has the above advantages?