Skip to content

Instantly share code, notes, and snippets.

@sergiosvieira
Last active January 31, 2024 01:22
Show Gist options
  • Save sergiosvieira/8d848883a53267e720f3bd00d3901c91 to your computer and use it in GitHub Desktop.
Save sergiosvieira/8d848883a53267e720f3bd00d3901c91 to your computer and use it in GitHub Desktop.
Git Workflow for Small Teams

Git Workflow for Small Teams

  1. Create a development branch on your local repository.
$ git checkout --track origin/development
  1. Work on your task as usual. Remember to make frequent commits to keep track of your progress.
$ git checkout -b task_name # Create the task branch
  1. Keep your local task branch up-to-date with the remote development branch, including any updates your team makes.
$ git checkout development # Switch to the development branch
$ git pull origin development # Update the development branch
$ git checkout task_name # Switch to the task branch
$ git rebase development # Do a rebase

Explanation about Git Rebase: <URL inválido removido>

WARNING: THE LAST COMMAND (REBASE) MAY CAUSE CONFLICTS, YOU WILL NEED TO RESOLVE THEM BEFORE CONTINUING.

  1. Once your task is complete, squash all the small commits into a single commit.
$ git rebase -i development

4.1 When your editor opens, edit the text displayed so that all the commit messages are combined into a single commit. See the example below: Original

 pick ae3a3dc Adding first part of new feature
 pick 3c82ad8 Adding second part

How it should look

 pick ae3a3dc Adding first part of new feature
 squash 3c82ad8 Adding second part

WARNING: Replace all 'pick' with 'squash' from the second line onwards.

  1. Merge your task branch with the local development branch, then push it to the remote development branch.
$ git checkout development # Switch to the development branch
$ git pull origin development # Update the development branch
$ git merge task_name # Merge the changes from your task branch into the development branch
$ git push origin development # Push the changes to the development branch
  1. Delete your local task branch when it is no longer needed.
$ git branch -d task_name

Releasing a Version

Once all the tasks for the release are ready, do the following:

  1. Merge the development branch with the main branch.
$ git checkout main
$ git merge development
  1. Name the release using the following notation: major.minor.patch
$ git tag 1.0.0
  1. Push your changes.
$ git push
$ git push --tags

Found a Bug?

What happens if a bug is found in production? Do the following:

  1. Fix the bug directly on the main branch.
$ git checkout main

(..) Make the necessary fixes (..)

$ git commit -m "Bug Fix: description of the fix"
  1. Name it as a patch release (major.minor.patch)
$ git tag 1.0.  # <- put the patch version here
$ git push --tags
  1. Push the changes to the main branch.
$ git push origin main
  1. Merge the main branch with the development branch.
$ git checkout development
$ git merge main

WARNING: IF CONFLICTS OCCUR WHEN MAKING THE MERGE, RESOLVE THEM.

  1. Push the changes to the development branch.
$ git checkout development
$ git push origin development
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment