System for managing electronic locks of public toilets.
Instead of a single main
branch, we use two branches (potentially three if we decide to later add the staging branch) to record the history of the project. The main
branch stores the official release history, and the develop
branch serves as an integration branch for features.
develop
is a default protected branch. Protected means that nobody can push code directly to it. Actual work always happens on feature (and bugfix) branches.
Each new feature should reside in its branch. But, instead of branching off of main
, feature branches use develop
as their parent branch. When a feature is complete, it gets merged back into develop
(pull requests + code reviews). Features should never interact directly with main.
These branches adhere to the same rules and principles as feature branches but are used to fix bugs, not implement new features.
Important note: Temporary branches must not be deleted (Project specific behavior)
Collectively, feature and bugfix branches are known as temporary branches. As the name implies, these are disposable branches that can be created and deleted by the need of the developer or deployer. Most conventions recommend leading the branch name with prefixes like hotfix
, feature
, or some other variant of the categorization of tasks.
- Branch name start with a type keyword (
feature
orbugfix
) - Next comes the
/
sign - The third thing is the GitHub issue number
Note: this means that for every branch an issue needs to be created. Normally, issues get created before branches because they define what needs to be done and how. - Next comes the
_
sign - The last thing is the name of the issue with
-
instead of the spaces
For example, if we have an issue on GitHub named "Implement login form" and it's an issue #10, the branch name should be feature/10_implement-login-form
.
- we first
checkout
to thedevelop
branch git pull
- getting the latest updates from the repo- IMPORTANT to pull every time we need to make a new
feature
orbugfix
branch
- IMPORTANT to pull every time we need to make a new
git checkout -b feature/[issue number]_[key-words]
- commit changes on our branch
- after we complete the issue, we push the changes on the remote repo with
git push
- open PR (pull request) to merge the
feature
orbugfix
branch to the develop branch- set someone as a reviewer to give feedback or confirm the merge
- we merge to the
develop
branch
SCENARIO: you accidentally made some changes on a wrong branch
git stash
- saves all the changes in the "clipboard"
git checkout [branch-we-should-be-on]
- if we didn't create the branch, we add
-b
to the command
- if we didn't create the branch, we add
git stash pop
- pasting all the changes on the new branch
SCENARIO: you made a commit, but you forgot to stage a file or you wrote a wrong commit message
git commit --amend
- stage all the missing files then commit
- after the
commit --amend
, change the message
git commit --amend --no-edit
- same as the command before, but doesn't change the message