Reputation: 46796
I use git from mostly from a command line, but for conflicts resolving, I prefer an IDE. Specifically IntelliJ IDEA.
Currently I attempt a rebase, and see conflicts. So I need to go to IDEA and click "VCS -> Git -> resolve conflicts". And then go back to console and run git rebase --continue
.
I think I can configure git
to call a program to handle conflicts.
Is there a way to invoke IDEA's conflicts resolving from a command line?
Something like idea --git-resolve-conflicts $(PWD)
.
Perhaps after installing a right plugin? This is what IDEA gives me as help:
Usage:
/usr/local/bin/idea -h | -? | --help
/usr/local/bin/idea [project_dir]
/usr/local/bin/idea [-l|--line line] [project_dir|--temp-project] file[:line]
/usr/local/bin/idea diff <left> <right>
/usr/local/bin/idea merge <local> <remote> [base] <merged>
Upvotes: 6
Views: 4740
Reputation: 1180
First thing you have to define the tool to be used for merge resolution in ~/.gitconfig (global) or project/.git/config (just for your project)
[mergetool "idea"]
cmd = /usr/local/bin/idea merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"
trustExitCode = false
[merge]
tool = idea
then in a normal session, when after a git merge
command some conflict arises, call:
git mergetool
I edited modifying to false the trustExitCode settings... so that it does not fail when multiple conflicting files. After each file in the shell is asked confirmation whether the conflict about the current file is solved and then it proceeds with the next one.
Upvotes: 5
Reputation: 7528
You could call IDEA as a merge tool - /usr/local/bin/idea merge <local> <remote> [base] <merged>
. More information at https://www.jetbrains.com/help/idea/running-intellij-idea-as-a-diff-or-merge-command-line-tool.html
There is no way IDEA could find all conflicts on its own, but you could configure it as the default merge tool for git, as proposed by Carlo. This should work
Upvotes: 4