Git to a Web-server : How To Set remote git server to automatically merge the branch after pushing?

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)

  • How to add a git repository as a shared dependency of another git repository?
  • Remove files tracked by Git
  • Git branch checkout says files would be overwritten alothough my working directory is clean
  • Selecting commits to send in a pull-request
  • Git refusing to merge unrelated histories
  • Why do we use double dash in “git checkout — .”?
  • Composer: Multiple Packages in one Repo
  • Make git ignore files
  • Is it possible in git to just push 4 out of 5 commits?
  • LibGit2Sharp Find what files were updated/added/deleted after pull
  • Getting the remotes along when pulling a local repo
  • How to push a git submodule to AWS Elastic Beanstalk?
  • One Solution collect form web for “Git to a Web-server : How To Set remote git server to automatically merge the branch after pushing?”

    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:

    git init --bare

    That will fix the error you got when pushing to the server.

    Git Baby is a git and github fan, let's start git clone.