简体   繁体   中英

Git workflow and deployment, with sync

I've been searching all around for a workflow that fit for us, but still I can't find a complete one. Hope you can help us, a simple team of two developers!

As far as I understand the best workflow is to push and pull all our changes to a common development server using git, and then have these changes uploaded to the deployment server.

There's many guides for this, and it's easy to solve if all the changes is made by us developers. Our problem, which I thought would be common, is that a lot of changes is happening on the deployment server as well. A common one is when an end-user is uploading new images in their CMS. Some end-users are even editing CSS-files through the CMS-interface. How do we get our development server and deployment server in sync? Git? Rsync? Combination?

/Martin

It's a common practice to not track user related changes by git so you never need to update the repository from the production server side.

User images should be placed in a separate directory, central asset server or on Amazon S3 for example. It's also a good idea to store CMS related changes in a database.

You have to, conceptually, separate code changes from content changes (especially user generated content). Git isn't good for making whole site backups, so indexing rapidly changing user content is just going to create an excessively sized repository that is inefficient and, most importantly, not portable.

Use Git to track changes to the files that allow users to edit/contribute/maintain their content. Use a centralized server (we use gitolite) for your workflow on that. As @iltempo mentioned, separate the user generated content and keep it out of your repository using .gitignore .

With Git repositories, you can use git hooks to execute scripts - a lot of people use these for automated deployment, but you could easily use rsync there to backup and sync your servers automatically. rsync is perfect for this as you have the option to only add new content, keeping transaction times lower. So, conceptually, git takes care of code, rsync takes care of everything else, and git hooks make it happen.

We use this with our CMS and it is a lifesaver.

Roughly, you need to exclude some folders/files from the source tree and/or deployment process. Rsync is ok for that.

Are you looking to do continuous integration ?

To automate your workflow I would suggest using Jenkins .

With Jenkins you can automate your builds, automate testing if possible, and you can even deploy your app whenever a commit is pushed to the Git repository, to a staging server or to production.

Jenkins is not limited to Java projects, you can build any project with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM