daugaard47
2 weeks ago
1173
3
Servers

How to Push a GIT Branch to a Live Testing server

Posted 2 weeks ago by daugaard47

As the title states, I want to figure out a workflow to test my GIT Branches on a Live server before merging to master and pushing to production.

This is my current GIT Workflow:

I should note on my server the repo's are in /var/repo/dev.git and /var/repo/site.git and sync to my /var/www/(dev & site folder)

Here is the folder structure:

folder stucture

Inside dev.git and site.git

#HEAD
ref: refs/heads/master
---------
#CONFIG:
[core]
    repositoryformatversion = 0
    filemode = true
    bare = true

Inside the folder refs there is a folder called heads and a file called master. There are also other files that are named the same name as my branches I've tried to push.

branches

For simple changes:

  1. I work directly on the Master Branch, Locally.
  2. Then Push to a Live Staging server dev.example.com to make sure everything is running smooth
  3. Then push the master to the Live Production server example.com
git status
git add *
git commit -m "My Change"
git push // Pushes to Master Branch on Git Hub
git push staging // Pushes to my live staging server
git push production // Pushes to my live production server

For Branches:

  1. I create a new branch locally git checkout -b newbranch.

  2. Then Push to newly created branch on GitHub git push origin newbranch

  3. When on the newbrach I push to GitHub then try and push to git push staging or git push staging newbranch, but no changes are made to my staging/dev server

  4. So I have to git everything working on that branch locally

  5. Merge to the Master Branch

  6. Then push to Staging and hope all is working smoothly

  7. The push to Production

I want to figure out how to Push my working branch to my Live staging server so I can run Live Tests. Then Merge to Master and Push to Production.

Here is a nice little diagram of what I'm currently doing and what I want to do.

Note, I want to do illustration #3 in the diagram. enter image description here

Please sign in or create an account to participate in this conversation.