In this tutorial you will learn how to create and switch to a branch on the same time in Git using “git checkout -b” command.
Code used during this tutorial:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# Git Create and switch to a branch on the same time # Get some info about the current project git status git branch # Create "feature_1" branch from "master" branch git checkout -b feature_1 git status git branch git log -n 2 # Create file and commit it echo "Hello world" > file-4.txt git status git add file-4.txt git commit -m "file-4.txt with Hello world content" # Create "feature_2" branch from "feature_1" branch git checkout -b feature_2 git status git branch git log -n 2 ls -l git checkout feature_1 ls -l |