🌿 BranchingCommonly used
How to create a new branch in Git
Create a new branch to work on a feature or fix.
Create and switch to new branch
git switch -c feature/my-featureCreates a new branch and switches to it immediately. Modern syntax (Git 2.23+).
When to use: Recommended for Git 2.23+. Cleaner than checkout.
Create and switch (older syntax)
git checkout -b feature/my-featureClassic way to create and switch to a new branch. Works in all Git versions.
Create branch without switching
git branch feature/my-featureCreates the branch but stays on the current branch.
When to use: When you want to create a branch but keep working on the current one.
Create branch from a specific commit
git switch -c hotfix abc1234Creates a new branch starting from a specific commit hash.
When to use: Creating a hotfix from a specific point in history.