Git workflow for small web team

2020-07-23 05:38发布

问题:

I know there are already many questions here on this topic, but I've had trouble finding exactly what I need.

We're a small team of developers currently using SVN but soon to be making a switch to Git. We are used to checking in changes and pushing to the live website throughout the day but currently lack any formal testing procedures, which is something we'd like to add. The way I'm used to doing this with SVN is:

  • develop in a personal test environment
  • check in your changes
  • send the current repository files to a global (production-like) testing webserver, and test
  • send the current repository files to the live webservers

This obviously can create some problems, especially if communication is not good. I've experienced times when untested changes have gone live and that's something we'd definitely like to avoid.

What I'm envisioning is a master Git repository that holds the tested code that is running on the live servers. Then have a clone of that repository that is used to test revisions. I'd like to have a script that is responsible for pulling changes from the requesting developer, putting them in a branch on the test repository, and running some automated tests to make sure nothing major is broken. When that all checks out, that branch can be merged and pushed up to the master and out to the live servers.

I'd like to hear any comments about this possible workflow and any suggestions for improvement or how to do it differently. Also, any specifics on how to set this up would also be appreciated. Thanks!

EDIT: I've used the above method for a while now and it's worked out pretty well.

回答1:

Do you really need a separate repository? Your live code is only a single branch; you can use other branches for "deploy candidates" under testing.

You don't necessarily need a script to pull the changes - developers could just push them to a separate branch, then invoke a script to test that branch.



回答2:

Have you considered code review? Gerrit might help.
(See Android's Gerrit instance for an idea of the functionality you get.)

You could then set up a testing environment that would pull a change or set of changes from refs/for/master to the test server.

This is quite fuzzy in my head, but maybe you find it a useful pointer.



回答3:

I found this to be extremely helpful:

http://nvie.com/posts/a-successful-git-branching-model/



标签: git workflow