Reputation: 1478
When I try to make a "git pull" I get the following message :
error: The following untracked working tree files would be overwritten by merge: blablabla.iml Please move or remove them before you can merge. Aborting
I try to checkout the .iml and add it to my gitignore but I keep receiving this message. Does someone know how to fix it?
Regards
Jose
Upvotes: 1
Views: 1522
Reputation: 17342
Git will not allow you to execute a pull that would cause you to lose changes in your working directory (this is good for obvious reasons).
Adding the file to your .gitignore will tell git not to push your changes to that file to other repositories, but it does not prevent you from pulling other repositories changes of those files. So this actually has no effect on the operation you are trying to do. As a side note, it is not recommended to put iml files in a .gitignore: What should be in my .gitignore for an Android Studio project?.
Here's what I would do:
git stash save "My iml changes"
git pull
git stash pop
. Or, if you prefer, git stash drop stash@{0}
(As pointed out by @LoyalRayne, you might not need these changes). See the differences with git stash show stash@{0}
.Upvotes: 2
Reputation: 19035
If you want the contents that are currently in the repo, you can revert your local changes first with git checkout blablabla.iml
, then pull. Or, if you want to keep your local changes, do git stash
, then git pull
, then git apply
.
After doing the above steps, you may add the file to .gitignore
. Make sure to remove it from source control as well with git rm --cached blablabla.iml
. Note that when it is remove from source control, it will get deleted on other people's machines when they do their next git pull
, so they will want to create a backup.
Upvotes: 1