Branching With Git (Basic)

On the internet many tutorials will use git checkout but git switch is a (not so) new feature and more clear to use.

After git init we will have one branch called master

To work on a new feature, create and switch to a new branch:

git switch -c <new_branch>

List the branches:

git branch

To switch to a branch:

git switch <branch_name>

Of course also on the branch:

git add .
git commit -m <message>

When done merge the branch with a commit message:

git switch master
git merge <new_branch> -m "<Commit Message>" --no-ff

And delete the branch:

git branch -d <new_branch>
Git series
All posts in Git
  1. Git(hub)
  2. Keeping files synchronized (github)
  3. Branching with git (basic)