Branching is Git's killer feature. Branches allow you to diverge from the main line of development and continue to do work without messing with that main line.
Renaming your default branch from master to main is a common modern setup step. #setup #init #master #main
git branch -M mainMoving between different branches updates your working directory to match the commit at the tip of that branch. This interactive command shows you the commit subject alongside the branch name so you know exactly what work is on that branch before you switch to it. #checkout #switch
git switch $branchWhen you start working on a new feature or bugfix, you should create an isolated branch. This creates the branch and immediately checks it out.
git switch -c $new_branchDeleting a branch removes the pointer to the commit, but the commits themselves might still exist until garbage collected. This command safely deletes the branch only if it has been merged. #rm-branch #remove
git branch -d $branch_delRename an existing local branch. #mv-branch #rename
git branch -m $branch $new_branchMerging integrates the history of one branch into another. You can choose to fast-forward if possible, force a merge commit (--no-ff) to preserve the feature branch history, or squash everything into a single commit on the target branch. #combine #join
git merge $merge_flags $branch_merge