-
Notifications
You must be signed in to change notification settings - Fork 45
Git Workflow
This documents our command-line git workflow. Many of these actions have equivalents in your IDE. Feel free to use them, but for best results you should understand the underlying commands that the IDE is executing.
- Checkout out the master branch on your local machine and pull in the latest changes:
git checkout master
git pull --rebase origin master
- To start working on a new feature (ideally one that's captured as a user story in Pivotal), create a new branch:
git checkout -b name-of-feature
- Try to break the feature into relatively stand-alone chunks. These chunks may not all deliver any user-visible functionality, but they should be testable. Before each commit, run tests like this
./manage.py test
npm test
./manage.py test integrationtests
Of course this also means you need to write tests for the code you've just written. When the tests pass, you're ready to commit:
git commit -am "My changes"
-
Push your branch to remote:
git push origin name-of-feature
-
Open a Pull Request on Github and request a code review from another team member in the Workbench Slack channel.
-
Your reviewer will either request additional changes (go back to step 2 and repeat!) or merge your changes and delete your topic branch from remote.
-
Delete your topic branch from your local copy:
git branch -D name-of-feature
For anything that will require more than one commit, use a branch as above. Otherwise:
- Checkout out the master branch on your local machine and pull in the latest changes:
git checkout master
git pull --rebase origin master
- 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
./manage.py test integrationtests
- Check what you've changed. Use the GUI in your editor (VS Studio, PyCharm) or do
git diff
If you discover you've edited some file and you want to undo all your changes on that file (warning will destroy all your edits), you can undo all of your edits with
git checkout [filename]
- If it all looks good, commit. Again you can use your GUI, or to commit all changed files do
git commit -am "My changes"
- Push to the server
git push
- At this point you may discover that other people have pushed before you. If others have commits on master ahead of you, do
git pull --rebase origin master
- 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 origin master