Search code examples
ruby-on-railsgitherokumergegit-merge-conflict

Git merge conflict with workspace.xml


I'm trying to push my Rails project to Heroku, but Git isn't allowing me to do anything at the moment. Here's what I've done so far:

  • git push heroku failed because the heroku branch was "ahead" of my local branch, which should not have been possible.
  • I pulled and there was a conflict with .idea/workspace.xml. I wasn't able to find out what that file is, but it's huge and Git wrote all kinds of garble to it. Too much to manually "resolve" conflicts.
  • I saw some stackoverflow posts talking about git-ignoring that file (maybe it's some IDE file for RubyMine or something?), so I tried to move the file away to avoid the conflict
  • I ran git add -A (also tried git add . and git add)
  • git commit --amend fails because "You are in the middle of a merge"
  • git merge --abort fails because "Untracked working tree file '.idea/workspace.xml' would be overwritten by merge (despite the fact that the file has been moved)
  • git reset --merge fails for the same reason.

How can I make Git work again?


Solution

  • .idea/workspace.xml

    This file is your idea workspace files. They are generated by IntelliJ tools.

    I saw some stackoverflow posts talking about git-ignoring that file (maybe it's some IDE file for RubyMine or something?), so I tried to move the file away to avoid the conflict

    Simply add the folder to your .gitignore but since its already committed you will have to remove it from the repository:

    # Quit the merge
    git merge --abort
    
    # remove the whole folder from the repo
    git rm -rf --cached .idea/
    
    # add it to the .gitignore: idea/
    
    # add and commit your changes
    git add .- A
    git commit -m " Removed idea folder"
    
    git push origin <branch> 
    

    If you still unable to do it?

    First reset the code to the previous state and then do the above code again.
    The reset will take you to your last commit before the pull