Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can't checkout master on a branch pipeline

I have a pipeline that runs when pushing to a branch. I created a manual step to merge that branch back to master. Triggering this step, checking out master always fails.

  - git remote set-url origin https://username:${GIT_SECRET}
  - git remote show origin
  - git fetch origin && git branch -avv && git checkout master

Here's I'm using app passwords, but I tried SSH keys to no avail.


> git remote show origin

* remote origin
  Fetch URL: https://username:$
  Push  URL: https://username:$
  HEAD branch: master
  Remote branch:
    pipelines-merge tracked
  Local branch configured for 'git pull':
    pipelines-merge merges with remote pipelines-merge
  Local ref configured for 'git push':
    pipelines-merge pushes to pipelines-merge (up to date)
> git fetch origin && git branch -avv && git checkout master

* pipelines-merge                2685089 [origin/pipelines-merge] merge back to master
  remotes/origin/pipelines-merge 2685089 merge back to master
error: pathspec 'master' did not match any file(s) known to git.

* pipelines-merge: the branch to merge from

Any variation on authentication method & checking out produces the same result. It's like any other branches are invisible to the pipeline.

Is this expected? What am I doing wrong? Thanks in advance!


3 answers

1 accepted

2 votes
Answer accepted

I was able to reproduce the error locally. The culprit is the parameter `--depth`. Specifying `depth: full` on bitbucket-pipelines.yml should fix, but then this applies to all steps. I need to do this only in a single step.

Here is the solution on step level.

- step:
- git fetch --unshallow
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch origin
- git checkout --track origin/master

I've found this on link

Also, there is the issue created for defining clone depth per pipeline

Specifying `depth: full` also work for me,

Thank you Andre

where do you set this?

This is an example:

  depth: full
    - step:
        name: Cloning
          - echo "Clone all the things!"

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,925 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you