Skip to content
Git
Branching

Branching

Git branches are like independent copies of your project. They exist to allow you to make changes to the project without impacting your currently functioning version.

Most common git branch names

main - this is your main branch, which you aim to keep fully functional.

dev or development - this is the branch on which you test and make changes.

[feature] - these kinds of branches are for creating and testing a particular feature.

release/x.x.x - these are branches for releasing particular version of the software.

[task] - e.g. hotfix/, bugfix/, chore/ - for particular tasks

Create a branch

List your existing branches: git branch

Create and switch to a branch: git checkout -b new_branch

Switch to an existing branch: git checkout branch

Merge two branches

First, switch to the branch you want to merge with: git checkout branch

Then, merge with the new_feature branch: git merge new_feature

Push local branch to remote

First, switch to the branch you want to merge: git checkout branch

Now: git push -u origin your_branch_name

This command pushes the changes from branch your_branch_name to the upstream branch origin (-u origin)