Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not checkout a git branch from a bitbucket pipeline yml script

I want to have rebase on top of staging (or merge with staging) before I deploy to my QA server so it will contain the latest changes + changes from my branch.

As a first step I tried to checkout staging and failed: I have the following configuration in bitbucket-pipelines.yml

merge:
- step:
    name: merge with staging
    image: node:8
    script:
    - git remote update
    - git fetch origin
    - git branch -f staging origin/staging
    - git checkout staging

error:

+ git branch -f staging origin/staging
fatal: Not a valid object name: 'origin/staging'.

I did try a lot of other variants that are work locally but everything fails... looks like bitbucket limits access to other branches..

What is the correct way of checking out branches in bitbucket pipelines?

like image 284
31415926 Avatar asked Nov 07 '22 19:11

31415926


1 Answers

Before the fetch command, you need to configure it with this:

- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
like image 181
videomugre Avatar answered Nov 13 '22 01:11

videomugre