Merging Git LFS repository failing due to local changes
Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.
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
git config -lin 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
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.
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.