Tutorial hero image
Lesson icon

Git Workflow Cheat Sheet

1 min read

Originally published June 04, 2021

This is a cheat sheet for the Git workflow described in this tutorial: A Simple Project Management Workflow for Ionic Developers. For more information on setting up the workflow initially, please read that tutorial. This cheat sheet will only contain the commands needed for using this workflow after the initial set up.

Starting work on a new issue

  1. Checkout and update the main or master branch with the latest changes:
git checkout main
git pull
  1. Create a new branch using the format [your-initials]-[issue-number] or any consistent format you prefer:
git checkout -b jm-10
  1. Send changes back to the remote branch referencing the relevant issue number in the commit message:
git add .
git commit -m "#10 added E2E test"
git push --set-upstream origin jm-10

NOTE: --set-upstream origin branch-name is only required for the first push back to the remote repository

Finishing work on an issue

If the work is complete and does not require a refactor or review, use the closes syntax to automatically close the relevant issue and move it to the Done column in the Kanban board:

git add .
git commit -m "closes #10 finished the feature"
git push

Merging back into the main branch

  1. Make sure main or master is up to date:
git checkout main
git pull
  1. Merge changes from main into your branch:
git checkout jm-10
git merge main

NOTE: If there are conflicts (i.e. a change you have made collides with a change in main) you will see a message stating which files contain conflicts. You will need to open these files, resolve the conflicts, and then add/commit those files. Keep in mind that after running git merge you can run git merge --abort to undo that action.

  1. Merge the branch into main:
git checkout main
git merge jm-10
git push

(Optional) Remove the branch

git push origin --delete jm-10
git branch -d jm-10

If you enjoyed this article, feel free to share it with others!