First of all, im new to Git and Git hooks. Here’s what im trying to do… I want to create a local git repository where I’ll work on my website. Then, I want to setup a git repository in my webserver and push the changes directly from my machine to the server using git. For this, what is the best path?
- I followed some online guides and did this…
- Initiated a repository on the remote server.
- Initiated a repository on my local machine
- Made a commit
- Switched to a different branch (Can’t push the master branch to the server (If I can, its a lot easy))
- Pushed that branch to the server
- Logged into the server and merged the branch into the master from within it
My questions are,
Is this the best way to do the job?
If it is, can I do the merging part using hooks automatically? (How to do it? Im new to hooks)
Reading your question and the comment – the problem is with the way you initialized the repository on your server.
On your server you need to initialize a bare repository, using the following command:
That will fix the error you got when pushing to the server.