main
- main branchdev
- development branchfeat/
- feature branchfix/
- bug fix branchhotfix/
- hotfix branch
Main branch is the main branch of the project. It is the branch that is deployed to production. It is protected and cannot be pushed to directly. It can only be updated by merging a pull request from development or hot fix branch .
Development branch is the branch that is used for development. It is protected and cannot be pushed to directly. It can only be updated by merging a pull request from feature branch or bug fix branch.
Feature branch is the branch that is used for developing a new feature. It is created from the development branch.
Bug fix branch is the branch that is used for fixing a bug. It is created from the development branch.
Hotfix branch is the branch that is used for fixing a bug in production. It is created from the main branch.
Pull requests are used to merge a branch into another branch. Pull requests are required to be reviewed and approved by at least one other developer before they can be merged.
- Create a new branch from the development branch
- Make changes to the new branch
- Commit changes to the new branch
- Push the new branch to the remote repository
- Create a pull request to merge the new branch into the development branch
- Review and approve the pull request
- Merge the pull request
- Delete the new branch
feat:
- for new featuresfix:
- for bug fixesdocs:
- for documentation changesstyle:
- for formatting, missing semi colons, etc; no code changerefactor:
- for refactoring production codetest:
- for adding tests, refactoring test; no production code changechore:
- for updating build tasks, package manager configs, etc; no production code change
-
git init
- initialize git repository -
git add .
- add all files to staging area -
git commit -m "message"
- commit changes -
git branch
- list branches -
git branch -a
- list all branches -
git branch branch-name
- create branch -
git checkout branch-name
- switch to branch -
git checkout -b dev
- create and switch to dev branch -
git checkout -b feat/branch-name
- create and switch to feature branch -
git checkout -b fix/branch-name
- create and switch to bug fix branch -
git checkout -b hotfix/branch-name
- create and switch to hotfix branch -
git merge branch-name
- merge branch into current branch -
git branch -d branch-name
- delete branch -
git push origin branch-name
- push branch to remote -
git push origin --delete branch-name
- delete remote branch -
git push origin :branch-name
- delete remote branch -
git pull
- pull latest changes -
git pull origin branch-name
- pull branch from remote -
git fetch
- fetch latest changes -
git fetch origin branch-name
- fetch branch from remote -
git rebase branch-name
- rebase current branch onto branch -
git rebase --continue
- continue rebase after resolving conflicts -
git rebase --abort
- abort rebase -
git stash
- stash changes from working directory -
git stash pop
- apply stashed changes to working directory -
git reset HEAD~1
- undo last commit -
git reset --hard HEAD~1
- undo last commit and remove changes -
git log
- show commit history -
git log --oneline
- show commit history (compact) -
git log --graph --oneline --all
- show commit history (compact graph) -
git log --stat --summary
- show commit history (detailed) -
git log --patch
- show commit history (very detailed)
git config --global alias.co checkout
- git cogit config --global alias.br branch
- git brgit config --global alias.ci commit
- git cigit config --global alias.st status
- git st