Summary
      When using repositories with Git Large File Storage (LFS) and a merging scheme such as Branch Updater, the merge fails with the following error in server logs:

      2018-11-01 10:20:16,361 WARN [6-DelayedChangeDetectionThread:pool-12-thread-65] [ChainExecutionManagerImpl] Merge command error: com.atlassian.bamboo.plugins.git.GitCommandException: command [/bin/git merge --no-commit 370affcfbe4f62d50ecf04fb64ab7c559f093b62] failed with code 128. Working directory was [/bamboo-home/xml-data/build-dir/serverSide/PROJ-BRAN10-1/mergeWorkspace]., stderr:
      error: Your local changes to the following files would be overwritten by merge:
      

      Steps to Reproduce

      1. Setup repository with LFS and 2 branches: master and develop
      2. Create plan at Bamboo and link to this repository
         final Plan plan = new Plan(new Project()
                        .key(new BambooKey("TEST"))
                        .name("Test"),
                    "LFS",
                    new BambooKey("LFS"))
                    .pluginConfigurations(new ConcurrentBuilds()
                            .useSystemWideDefault(false))
                    .stages(new Stage("Default Stage")
                            .jobs(new Job("Default Job",
                                    new BambooKey("JOB1"))
                                    .tasks(new VcsCheckoutTask()
                                            .description("Checkout Default Repository")
                                            .checkoutItems(new CheckoutItem().defaultRepository()))))
                    .linkedRepositories("Mvnrepos")
                    .triggers(new RepositoryPollingTrigger())
                    .planBranchManagement(new PlanBranchManagement()
                            .createForPullRequest()
                            .delete(new BranchCleanup()
                                .whenRemovedFromRepositoryAfterDays(7)
                                .whenInactiveInRepositoryAfterDays(30))
                            .branchIntegration(new BranchIntegration()
                                    .integrationBranch(new PlanBranchIdentifier(new BambooKey("LFS"))))
                            .issueLinkingEnabled(false));
        
      3. Do a commit to develop branch which affects file under LFS control, e.g. sample.zip which should exists in both branches
      4. Do a commit to master branch which creates another file under LFS control, e.g. sample2.zip which exists only at master branch
      5. Create pull request at repository develop -> master and wait for build.

      Expected Results

      The branch merging succeed and the build will be sent to the queue

      Actual Results

      It will fail to merge develop and master branches with error message

      error: Your local changes to the following files would be overwritten by checkout:
      	sample.zip
      Please commit your changes or stash them before you switch branches.
      Aborting
      

      Workaround

      There is no verified workaround.

            [BAM-20159] Automatic branch merging fails when using Git LFS

            Steven Roodhorst added a comment - - edited

            We experience this for every LFS change in the branches vs the master when bamboo tries to merge the master with the branches before building. Our manual workaround is to manually rebase or merge the master in the branch when this occurs.

            Using Bamboo server version 6.7.1 build 60705

            Steven Roodhorst added a comment - - edited We experience this for every LFS change in the branches vs the master when bamboo tries to merge the master with the branches before building. Our manual workaround is to manually rebase or merge the master in the branch when this occurs. Using Bamboo server version 6.7.1 build 60705

            Also affects versions < 6.7.1

            Workaround: run "git lfs uninstall" on the master server to solve the merge conflict, but you still need the git-lfs RPM installed when working with LFS repositories. This is because the built-in branch updaters use Bamboo master server for merging before the plan's initial stage.

            Edwin Miltenburg added a comment - Also affects versions < 6.7.1 Workaround: run "git lfs uninstall" on the master server to solve the merge conflict, but you still need the git-lfs RPM installed  when working with LFS repositories. This is because the built-in branch updaters use Bamboo master server for merging before the plan's initial stage.

              Unassigned Unassigned
              gribeiro Gabriel Ribeiro
              Affected customers:
              4 This affects my team
              Watchers:
              11 Start watching this issue

                Created:
                Updated: