Kristjan O.
Kristjan O.

Reputation: 914

multiple git branches on staging server

I recently started to use git and I'm having an issue. For example, everyone recommends to use as much branches as possible, but how do I make visible multiple branches on a staging server for my client to review all changes I have done in a single go? I do know that I can merge back branches to development (and then into master for live deployment), but how can I deploy all branches under development, so that client can see all the changes at once? I did update post-receive code to move the actual code to proper working directory and it also switches to latest branch pushed, but that's not a solution, I want to see all of them and when the time comes for pushing to live, I should be able to select which ones to push and which ones not (clients sometimes do not like new features or changes done ...).

Any recommendations? Is git even capable of what I'm trying to achieve?

Upvotes: 0

Views: 640

Answers (1)

sheltond
sheltond

Reputation: 1937

You can only have one branch checked out at a time in a single working copy of the repository.

The simplest approach to get what you want is probably to create a new branch for your test deployment, and merge each of the "feature branches" where you did your development to it.

That branch would contain all of the features that you choose to merge to it, so then you could push it to your staging server for testing.

Assuming that your stable code is in branch "master" and you want to test deployment of the changes in branches "feature1", "feature2" and "feature3" (and all of those were branched from master), and you have a remote set up called "staging" where you want to push to, something like this should work:

git checkout master
git checkout -b test_deployment
git merge feature1
git merge feature2
git merge feature3
git push staging test_deployment

Upvotes: 2

Related Questions