- Create a development branch on your local repository.
$ git checkout --track origin/development
- 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
- 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.
- 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.
- 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
- Delete your local task branch when it is no longer needed.
$ git branch -d task_name
Once all the tasks for the release are ready, do the following:
- Merge the development branch with the main branch.
$ git checkout main
$ git merge development
- Name the release using the following notation: major.minor.patch
$ git tag 1.0.0
- Push your changes.
$ git push
$ git push --tags
What happens if a bug is found in production? Do the following:
- Fix the bug directly on the main branch.
$ git checkout main
(..) Make the necessary fixes (..)
$ git commit -m "Bug Fix: description of the fix"
- Name it as a patch release (major.minor.patch)
$ git tag 1.0. # <- put the patch version here
$ git push --tags
- Push the changes to the main branch.
$ git push origin main
- Merge the main branch with the development branch.
$ git checkout development
$ git merge main
WARNING: IF CONFLICTS OCCUR WHEN MAKING THE MERGE, RESOLVE THEM.
- Push the changes to the development branch.
$ git checkout development
$ git push origin development