having a branch for live and development using git on server

So im fairly new to git and have been using if for a java project i am working on. I also manage the development of a website and want to start using git for that. It seems like there should be a way to do this, but I am not completely sure if it is possible. Anyways, here is what I’m hoping.

  1. have a live (branch?) repo that i can push to that stores what is live on the website
  2. have a production (branch?) repo that i can push to to view a staged version of the site. This will be contained in a subdirectory of the root of the server.

I read an article on how to make a git server.. but is what i have outlined above possible? I think it would make my life easier rather than having to remember which files i changed to FTP onto my server.


  • Using 'git checkout -f' to deploy files from a bare git repo in Gitlab
  • deploy wordpress database settings and not content
  • PHP Site Deployment Suggestion
  • how to find git merge commits which merges into current branch
  • Getting GIT repository updated from server conent
  • Automated heroku deploy from subfolder
  • How to create a restricted Git release branch that contains sensitive data?
  • git deploy minified assets only
  • 2 Solutions collect form web for “having a branch for live and development using git on server”

    Note that any git repo you are pushing to on a server should be a bare repo (that way, there is no synchronization issue between what you are pushing and the working tree, since a bare repo has no working tree).

    You usually push (the branch you want) to the bare repo, and you have a post-receive hook which will checkout the content of that branch to (one of your) web site directory, depending on the branch you have just pushed.

    See “how to process files on a branch in post-receive hook in git” as a concrete example.

    What your thinking of is having a master branch and a development branch. In general, anything that is pushed to the master branch by convention means that your application should be using that code. When you’re pushing to a development branch the code should be small fixes and improvements for your application. Later on these small fixes can be merged into your master branch so your application will be using it.

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