Optimal workflow for Local / Staging / Production server stack + Git
Asked Answered
Y

1

20

I am looking to incorporate a web development workflow that allows me to do the following:

  • Develop / Test locally
    • mimics production server (many subdomains, a few mysql DBs)
    • stays synced between desktop & laptop to allow on-the-go development
  • easily push local -> staging
  • easily push staging -> production
  • easily live-edit on the production server (occasionally need to for very minor content updates, typo changes, etc. Right now I spend a lot of time making small edits, pushing it to staging, then pushing to production which takes awhile for minor things.)

I am also new to Git. I have begun test the waters with Git in my personal projects, however the project I have inherited (with the production/staging environments) has not used any version control to this point.

Questions:

  • how can I easily adapt a large established project to a local environment (XAMPP)?
  • how can I sync my local environment between dev-laptop and dev-desktop?
  • Is Github worth it in this type of pre-established project / server setup? It seems like it adds a lot more steps (ex: local->push to git repo -> download repo to staging server -> push staging server to live server). Also I am concerned about maintaining privacy/security.

essentially I'm the single developer who was handed a fairly large project and I just want to try and make things as easy/straightforward on myself as possible. :)

Yardage answered 9/11, 2013 at 19:47 Comment(2)
What kind of project are you developing? The reference to XAMPP suggests PHP, but depending on the specifics of your project the details matter.Dominickdominie
@JoshKoenig primarily lots of LAMP, WordPress, and also sandboxing some Angular and Node-like libs. Just to play around. Would like to keep a fairly flexible environment.Yardage
O
15

Branches are one way to facilitate this workflow. There is a great blog post about how to use Git branches to manage a typical development workflow.

You would then have one branch for production (e.g. master), one for the live-edits which correspondes to the hotfix branch in the post above, and another one for development.

To sync your local environments on laptop and desktop, you can use the aforementioned development branch also as a remote branch and have both devices push their local commits on this branch to the remote repository.

Omidyar answered 10/11, 2013 at 2:33 Comment(1)
That post is great. I've wondered though, about the relative merit of using master for production. You could equally using master for development (in place of the existing "development" branch), and use a live branch for production (in place of the existing "master" branch). The only difference being that pull requests on some services like gitlab would automatically be directed at your main development branch, rather than the production branch. Not sure if there are any draw-backs to that though.Fabric

© 2022 - 2024 — McMap. All rights reserved.