Skip to content

Git Workflow

Jonathan Stray edited this page Jul 29, 2017 · 17 revisions

We have a small enough team that, for now, we do all work on the master branch. You do not need to create a feature branch for each feature, but you do need to avoid pushing breaking changes.

When you are ready to commit your changes:

  1. Make sure tests pass. This is a great moment to write your tests if you haven't already. All code, front and back end, needs unit tests.

     python manage.py test
     npm test
    
  2. Check what you've changed. Use the GUI in your editor (VS Studio, PyCharm) or do

     git diff
    
  3. If it all looks good, commit. Again you can use your GUI, or to commit all changed files do

     git commit -am "My changes"
    
  4. Push to the server

     git push
    
  5. At this point you may discover that other people have pushed before you. The default git approach is to do one big merge commit. But this ends up in a very messy large commit where like this one where it's impossible to see the actual changes. Instead, we use rebasing, which replays the new commits locally and appends your work on top of it. So if others have commits on master ahead of you, do

     git pull --rebase
    
  6. There may be conflicts. If so, edit each file with conflicts, then do

     git add <conflicted file>
    

to tell git you are done fixing that file. When done fixing and adding all merge conflicts:

    git rebase --continue

And finally:

git push