Merging and pushing to remote repository fails
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:
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+