Merging Git LFS repository failing due to local changes
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
Summary
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:
1
2
3
4
5
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
Run
git config -l
in the repository directoryIf the following is not included in the output, you may be affected by this issue:
1 2 3 4
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.
Solution
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
Was this helpful?