Is there a way to identify "collateral" commits (commits that are editing same lines and will result in a conflict) for the certain commit?
A very simplified example
$ git init
$ echo test > test
$ git add test
$ git commit -m "First commit"
$ echo test1 > test
$ git commit -am "Second commit"
$ git l
* 95a29dd Second commit
* 30a68e6 First commit
$ type test
test1
Assuming that at this point for whatever reason I want to revert 30a68e6
.
$ git revert 30a68e6
error: could not revert 30a68e6... First commit
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
Naturally, this will result in a conflict, since 95a29dd
, edited the same line.
Is it possible to find out in advance that reverting 30a68e6
would result in a conflict, and if so, with what commit (i.e. 95a29dd
)?
To give a bit of context, I need this, because I need some commits to be reverted automatically. In this case, if I know that 30a68e6
should be reverted, I want to be able to identify "collateral" commits, that should be reverted first to avoid any conflict (like 30a68e6
). I know that just reverting everything 30a68e6..HEAD
, would work, but I would like to avoid reverting commits that will not conflict with 30a68e6
.