# git: Add base branch support to create_branch \(\#42151\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/e025ee6a11729985666faf2507739c2522ba9f5a)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: e025ee6a11729985666faf2507739c2522ba9f5a

Requested commit: e025ee6a11729985666faf2507739c2522ba9f5a

Commit: e025ee6a11729985666faf2507739c2522ba9f5a

Tree: 85145e0ae946db25d1d179915b6a268f76bc3187

Author: Ayush Chandekar

Committer: GitHub

## Message

```
git: Add base branch support to create_branch (#42151)

Closes [#41674](https://github.com/zed-industries/zed/issues/41674)

Description:
Creating a branch from a base requires switching to the base branch
first, then creating the new branch and checking out to it, which
requires multiple operations.

Add base_branch parameter to create_branch to allow a new branch from a
base branch in one operation which is synonymous to the command `git
switch -c <new-branch> <base-branch>`.

Below is the video after solving the issue: 

(`master` branch is the default branch here, and I create a branch
`new-branch-2` based off the `master` branch. I also show the error
which used to appear before the fix.)

[Screencast from 2025-11-07
05-14-32.webm](https://github.com/user-attachments/assets/d37d1b58-af5f-44e8-b867-2aa5d4ef3d90)

Release Notes:

- Fixed the branch-picking error by replacing multiple sequential switch
operations with just one switch operation.

Signed-off-by: ayu-ch <ayu.chandekar@gmail.com>
```

## Parents

- [c60d31a726b014e1780f294a93208f4d3e6c60b3](https://git.cafe/gitcafe/zed/commit/c60d31a726b014e1780f294a93208f4d3e6c60b3?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/e025ee6a11729985666faf2507739c2522ba9f5a?format=markdown)
