On Sun, 5 Oct 2014 09:03:49 -0700 (PDT)
Oliur Chowdhury <o.r.chowdh...@gmail.com> wrote:

> Hi, this is a more of a guidance question:
> I've a local git repo which I then push to public_html/stage in
> siteground server.
> for each feature or bug issue I create a different branch and merge
> it with the master branch. I then push it to the server.
> I want to know if there is anyway I can test different branches in
> the browser url just like i can test the master branch.
> So, if I go to http://stage.tista.co.uk/ I can see the magento
> installation (which is my master branch).
> Is there a way I can also check different branches under the stage
> repo by going to a url?
> I did some googling but I didn't find anything. 
> I need a way to test the feature/bug branches to make sure it works
> before merging them with the master or pushing it to live. thanks

There's no way to do the testing you want using Git alone.
Here's why: when your browser performs an HTTP request, the web server
reads files located in the so-called "work tree" of your server-side
Git repository.  The work tree contains files as they are recorded in a
certain commit available in the repository (typically it's just the tip
commit of a certain branch).  Populating the work tree is called
"checking out" (that's why it's done using `git checkout`) and hence
the work tree is commonly called "the checkout" as well.

Hence the work tree can be thought of as a "view" to a certain commit
in the repository's history -- available for direct
inspection/consumption.  When your web server accesses the files in
your work tree, it just accesses the file system -- it does not know
anything about Git and does not call to it in any way.

As you can see, in a non-bare Git repository (that is, a repository
which has a work tree attached to it), there exists only a single work
tree, and the only way to "see" the state of the project as recorede in
another commit (say, the tip commit of another branch) is to check out
that branch to the work tree.

So what you can do about this?

I'm not much into web development myself but I think I can offer a bit
of advice anyway -- may be it sparks some idea in your head.

1) Have multiple work trees attached to the same repository, and have
   them available to the webserver via different vhosts of different
   pathname prefixes in the same vhost's URI.

   This is most easily done using the git-new-worktree script in the
   contrib section of Git sources.

   You could then automate your deployment using server repo's hooks
   to automatically check out tip commits of, say, "master" and "devel"
   in two work trees created beforehand.

2) Write a simple CGI script which would be accessible via that same
   web server and which would perform `git checkout` to the commit
   you tell it via a form provided by that CGI script.

(1) Requires more work up front but simplified side-by-side testing
while (2) requires less work up front but side-by-side testing is more
tedious (requires work tree updating when switching).

Also note that Git itself is not a deployment tool.  Magento heavily
relies on its database so only trivial changes are testable w/o messing
with the database when you're updating the staging server.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to