unable to create new branches: not through the bitbucket cli and not through terminal
Asked by Lottan Horev:

Hi everyone,

yesterday I couldn't create new branches that connected to the master in all my projects that exist on bitbucket.

when I create a branch through the bitbucket client, it gives me on the "checkout" command line, only the name of the new branch "feature/foo" and not the regular "git fetch \&\& checkout feature/foo" - the branch exists, but I cant perform checkout to it.

when I simply try "git checkout -b feature/foo" on the terminal when I am in the master branch, it creates a new branch, but without upstream and I can't push it or create a pull request.

Has someone had this problem before? can help on how to solve it?

thank you all,


Answers:
author: Caroline R
body: Hi, [@Lottan Horev](/t5/user/viewprofilepage/user-id/4606497)! Welcome to the community!

First of all, I would like to confirm that recently, the **git checkout** command has been removed from our UI due to vulnerability reasons. We understand that this may impact the workflow for some developers, so we have already created a feature request to add the git checkout command to the UI again as you can check here:

* <https://jira.atlassian.com/browse/BCLOUD-21422>

Now, going back to the problem you have reported about not being able to create new branches, you mentioned that after you created the branch on your remote repository, you ran the command "git checkout -b feature/foo". Indeed, it will create a new branch, however without upstream and you won't be able to push it or create a pull request.

In order to solve this issue, instead of running the command "git checkout -b {branch_name}" when you want to check out a remote branch, you need to run the following command:

```
git fetch && git checkout {branch_name}
```

This way, the branch will be set up to track the remote branch from origin and you will be able to push its content when you need to do so.

Please let me know how it goes and feel free to share any additional questions or concerns regarding this case.

Kind regards,  
Caroline

comments: author: Lottan Horev
body: Hi Caroline,

Thank you for your answer, still, when I try your solution I get this error:

repo git:(master) ? git fetch \&\& git checkout feature/foo  
error: pathspec 'feature/foo' did not match any file(s) known to git

do you have any recommendations for this scenario?

thanks,

Lottan


author: Caroline R
body: Hi, Lottan!

Thanks for getting back to me. I was only able to reproduce this error when the branch did not exist either in the remote or in the local repository. In this case, I would like to ask you a few things:

* Could you please confirm if the branch is created in the remote or in the local repository?

* Could you please check if the remote repository set in your local repo is correct? You can run the following command to verify that:

```
git remote -v
```

* If everything is correct: the branch exists in the remote repository and the remote is correctly set in your local repo, could you please run the following commands and let me know how it goes?

    git remote updategit fetch git checkout feature/foo

Looking forward to hearing from you.

Kind regards,  
Caroline


Tags: bitbucket-cloud

branch

cloud