Skip to content

git clones in containers cannot fetch other branches #1929

@sqqqrly

Description

@sqqqrly

Bug Report

When I look at the clone inside my container created by concourse (CC) for unit testing, I see a git config that is incorrect (or at least inflexible). The config prevents me from being able to fetch branches.

I want to use a passed-unit-tests branch in my repo-under-test and have CC rebase the passed-unit-tests branch on the tested branch. Then push the passed-unit-test branch back to origin. In this way, I can record in github that the UT passed on the tested commit.

I am unable to git fetch passed-unit-tests or any other branch other than develop.

Cause (.git/config):
fetch = +refs/heads/develop:refs/remotes/origin/develop
Solution:
fetch = +refs/heads/*:refs/remotes/origin/*

A snippit that works around the issue it in my bash script:

      40     info "+++ Remove git origin"
      41     git remote rm origin               || die "git remote rm origin failed"
      42
      43     info "+++ Add git origin"
      44     git remote add origin \
      45         "https://github.com/$gh_user/cc_test_app.git" || die "Cannot add git origin"

Alternative work around, but needing to handle branches other than develop:

sed -i -- 's?fetch = +refs/heads/develop:refs/remotes/origin/develop?fetch = +refs/heads/*:refs/remotes/origin/*?g' .git/config || die "git config fix failed"

Related to:
https://stackoverflow.com/questions/945654/git-checkout-updating-paths-is-incompatible-with-switching-branches
See the answer from Jul 5 '13 at 9:33 PålOliver

  • Concourse version: 3.6.0
  • Deployment type (BOSH/Docker/binary): docker-compose
  • Infrastructure/IaaS: None
  • Browser (if applicable): N/A
  • Did this used to work? No idea

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions