Jason G
Jason G

Reputation: 200

Why am I getting a commit error on IntelliJ - Commit failed with error

I'm using IntelliJ IDEA and I'm not sure where I'm going wrong, but I have another coder working on a section of an app (a branch called "additionalwork") that is on GitHub. All I want to do is to look at what he's doing before merging what he's done into the master branch. For some reason, when I make changes to my code and try to commit, I get an error:

enter image description here

Could someone tell me the steps I should be doing (or avoiding) so that I can not only work on my section of code, but view the other branch and then merge into the master branch if everything is ok with the other coder's work?

Upvotes: 1

Views: 7000

Answers (2)

Ruslan Kuleshov
Ruslan Kuleshov

Reputation: 2415

Please check the following:

  • In right lower corner you will see yellow sign with Merging
  • Under active changelist there should be "Merge conflict" tab with 'Resolve' Button, click on that.

Please resolve the conflict and then try to commit again.

Upvotes: 3

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521239

Without knowing exactly how you ended up in this state, just look at the error message from IntelliJ:

Committing is not possible because you have unmerged files.

You would typically end up in this because you did a git pull (or a merge with some branch), and ended up with merge conflicts. Therefore, the git pull/merge did not actually commit and complete, because Git expects you to manually resolve conflicts, and then commit yourself. So, to get out of this situation, you should resolve the conflicts and then git add each file from the bash or from IntelliJ, followed by a commit to complete the pull/merge.

One quick way you may identify which files in your project are in conflict would be to search for a merge conflict marker across your entire project in IntelliJ. So, try doing a SHIFT + CTRL + F for:

<<<<<<<
or
=======
or
>>>>>>>

Upvotes: 0

Related Questions