Sobes.tech
Junior — Middle

How can a separate branch be created in the Git version control system?

sobes.tech AI

Answer from AI

To create a new branch in Git, use the command git branch or git checkout -b.

Example of creating a branch and switching to it:

# Create a new branch named feature-branch
git branch feature-branch

# Switch to the created branch
git checkout feature-branch

Or a shorter way that creates and immediately switches to the branch:

git checkout -b feature-branch

After that, you can work in the new branch without affecting the main branch (for example, master or main).