Merging Git LFS repository failing due to local changes

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

When using repositories with Git Large File Storage (LFS) and a merging scheme such as Gatekeeper, the merge fails with the following error in the build log:

Merge command error: com.atlassian.bamboo.plugins.git.GitCommandException: command /path/to/bin/git merge --no-commit <hash> failed with code 128. Working directory was [<bamboo-home>/xml-data/build-dir/serverSide/<job-key>/mergeWorkspace]., stderr:
error: Your local changes to the following files would be overwritten by merge:
<list of files>
Please commit your changes or stash them before you merge.
Aborting

Diagnosis

Diagnostic Steps

  1. Run git config -l in the repository directory
    • If the following is not included in the output, you may be affected by this issue:

      filter.lfs.clean=git-lfs clean -- %f
      filter.lfs.smudge=git-lfs smudge -- %f
      filter.lfs.process=git-lfs filter-process
      filter.lfs.required=true

Cause

This issue is caused by Git LFS not being initialized on the system by the user running Bamboo. This is because Git LFS will add a pointer to each file, which will be seen as an update to non-LFS repositories.

Resolution

Please run git lfs install in a Git repository as the Bamboo user. This will initialize Git LFS for all repositories on your system.

This configuration is per user, so if you have previously run git lfs install as another user, you do still need to run it as the Bamboo user.

Note: If you only want to initialize Git LFS for one repository, you can do this by running git lfs install --local in the repository where you would like to use Git LFS.

References

 

Last modified on Nov 1, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.