About this question
How can you create a new branch in Git starting from an existing one? What commands let you branch off from another branch to begin new work without affecting the original?
How can you create a new branch in Git starting from an existing one? What commands let you branch off from another branch to begin new work without affecting the original?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask DevOps Expert
Answered on Aug 16, 2025
Creating a new branch in Git from another branch is a common workflow when you want to start new work based on an existing feature or code state. This allows you to keep changes isolated and avoid affecting the original branch.
Here’s how you can do it step by step:
Step 1: Switch to the Base Branch
First, make sure you’re on the branch from which you want to create the new branch.
git checkout existing-branch
Or in newer versions:
git switch existing-branch
Step 2: Create a New Branch
Use the -b flag to create and switch to the new branch at the same time:
git checkout -b new-branch
Or equivalently:
git switch -c new-branch
Step 3: Push the New Branch to Remote (Optional)
If you want this branch on GitHub or another remote, push it:
git push origin new-branch
Why this is useful:
Example Workflow:
If you’re working on feature-A but need to start feature-B from there, you can branch off directly:
In short, creating a branch from another branch ensures your new work inherits the latest changes while keeping everything organized and isolated.
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Most-read guides across JanBask
Common DevOps interview questions, answered
Guides, tips and career advice on DevOps from JanBask experts.
DevOps How to Become a DevOps Engineers: Learning Path, Critical skills & More
Looking for answer to how to become a DevOps engineer in 2025? Here is the detailed article about DevOps career path, DevOps…
DevOps Top 50+ Jenkins Interview Questions And Answers For 2025
Here are the Top 50 Jenkins interview questions frequently asked in top MNCs which will help you land an ideal job! These…
DevOps Best 37 DevOps Tools To Learn And Master In 2025: Docker, Git & More
Want to know what are Devops tools and their uses? Or looking for the best DevOps list for automation, monitoring, & development?…
DevOps DevOps Engineer Job Description: Roles and Responsibilities [2025 Updated]
Discover the essential roles and responsibilities of a DevOps Engineer by exploring the detailed DevOps job description, and…