How to work with Git Branches

Listing all branches with "git branch" command

Switch branch using git checkout

Switching to a existing branch with "git checkout" command

Create and switch to a new branch with "git checkout -b" command

Switch to a non-existing branch, the following error message will show up

Switch branch using git switch

A quick way of switching branch on Git is to use the “git switch” command and specify the name of the branch you want to switch to.

Create and switch to a new branch with "git switch -c" command

Switch to a non-existing branch, the following error message will show up

Merged branch to the master

First commit all your changes in your branch like your normally do, like

Then switch to the master branch

Check that you are in the master branch, now run "git merge" command

If all goes well then our job is done. The new feature commits now appear in the master branch.

Delete a local branch

To delete a local branch with "git branch -d" command

----------

Home

Linux

Notes

MicroLog

----------

© DarknessCode