Small project development flow

Janel Brandon
4 min readJun 10, 2019
Image from the Atlassian Git flow tutorial

A lot of new developers work on projects — for class, for their portfolio, to learn, by themselves, and with others. Mastering a good development flow can save a lot of frustration and panic, helping to ensure that your code remains stable and that your hard work isn’t lost.

In this article I’ll describe a flow that works really well when working on small to medium size projects. In larger projects, there would be more automation involved, but some of these practices would hold there too.

Git flow and repository

When you are working on a project alone or in a small group, it often makes sense to use a basic feature branching git workflow. I’m going to assume you are using this type of workflow, but there would just be a few changes if you are using a different kind of workflow.

In a feature branching workflow, there is one project repository that each team member clones directly (without forking). The master branch is considered the official project branch and should be kept as pristine as possible.

Deployment

In this article I’m going to talk about deploying to heroku, because it is commonly used for deployment by new developers (it’s free, easy to use, and there are lots of tutorials online). This article assumes you already have a heroku account, have installed the heroku CLI, and have logged in with heroku login.

To set up deployment on heroku you start from an established project git repository. From the repo directory, run:

heroku create <app-name>

The app name is optional — heroku will make one up if you don’t specify one, and you can change it later. This will create a remote connection to a repository hosted by heroku (you can see it with git remote -v). This is where your deployed code will go.

Depending on the type of app you’re deploying, you may have to set up some configuration variables (like the master key for a Rails project). You may have to run some commands on your deployed project (like heroku run rails db:migrate for a Rails project). There are lots of tutorials that can help you with these steps for the stack you are deploying.

When you want to deploy your latest code on heroku, just run:

git push heroku master

The workflow

For this example, assume we have a small team of developers, Jill, Tammy, and Jason, working together. Here’s how the development flow would go.

Jill wants to add the authentication feature

  1. Pull down the latest from master:
    git checkout master && git pull origin master
  2. Create a feature branch:
    git checkout -b authentication
  3. Jill does some code changes and tests in her local dev environment
  4. Add the change and commit to the local repo:
    git add . && git commit -m “added basic authentication support”
  5. Someone else may have updated master while Jill was working. Jill pulls master into her local feature branch and addresses any merge conflicts, and tests again if necessary:
    git pull origin master
  6. Push to the remote(origin) feature branch:
    git push origin authentication
  7. Jill raises a pull request and adds reviewers (in GitHub)
  8. Tammy and Jason review Jill’s change. If necessary, they pull the feature branch into their local repo and test it themselves:
    git pull origin authentication
  9. Tammy or Jason may request some changes. It is possible to add comments directly to the pull request and to request changes. If they do, Jill will follow steps 3–6 each time she makes a change. Every time Jill pushes a commit to the same feature branch, it will automatically update the pull request.
  10. When done, Tammy and Jason and approve Jill’s pull request (in GitHub)
  11. Jill merges her pull request into the project(origin) master (in GitHub)
  12. Jill pulls down project master her local (everyone else will need to also, but if everyone starts with step 1 every time, this is taken care of):
    git checkout master && git pull origin master
  13. Jill tests one last time in local
  14. It all looks good! Deploy!
    git push heroku master
  15. Test the deployed version
  16. If all is well, delete the local feature branch:
    git branch -d authentication

Complications can occur — but mostly if you stick to this workflow, things will go smoothly and your development experience with git and deployment will be less frustrating and more productive. My last piece of advice about this is to deploy early and often. Happy developing!

--

--

Janel Brandon

I have been working in software development for more than 20 years as a developer, sales advocate, teacher, certification developer, and engineering manager