Merging and pushing to remote repository fails

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

Repository merging/pushing with/to a remote branch in Script task does not work.

Cause

Bamboo creates Git workspaces copying a minimal set of data:

1 2 git init git fetch <remote-branch-ref>:<local-branch-ref>

Moreover Bamboo uses repository caching. It means that code is first fetched from remote repository to a local cache and then another fetch is made from this cache to a workspace that is placed in Plan's working directory. Thus said even if clone operations were performed instead of init/fetch combo we'd be still pushing to a remote which would actually be a local cache instead of real remote repository.This way Bamboo copies only a branch that should be build. Side effect of this is that workspace is not a full clone with information about all branches.

Resolution

Use Source Control task introduced in Bamboo 6.7+

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.