Ps. I don't want to perform a 3-way diff.
There are different settings in computer programming. Not everybody's job is part of devops, github, agile startups or some canonical open source workflow, but can still be working with programming. In our specific setting, we need to actively participate in each contribution independently of additional tools other than git. That said, once the changes are highlighted and editable, free from a cumulative process like Interactive Staging, one can use their local tool of choice to solve the 'conflicts' (actually, 'accommodate the changes').
Although there are some questions that sound similar to this one, none of them, neither their answers, address the general problem, which is useful not only for code in some contexts, but is specially important for documentation of code or other kinds of versioned text.
Say we have two branches main
(master
in my git version) and friend
(or origin
, depending on each particular case). I'd like to be able to accept, reject or edit each incoming change, since each one can be a reviewer of the text, and need to incorporate the changes/suggestions without changing the original intent. Another example is a supervisor receiving code from a student or the other way around. To be clear, this is not in a context of a bigger workflow, like GitHub, pull requests, etc. It is just pure git. Well, that's enough about the existence of such setting for who may be used to a different daily use of VCS.
Example:
mkdir force-conflict
cd force-conflict
git init .
echo -e "a\nb\nc\n" > file.txt
cat file.txt
# output:
a
b
c
git add .
git commit -m "First message"
Simulating friend's contribution:
git checkout -b friend
# output:
Switched to a new branch 'friend'
echo -e "d\n" >> file.txt
cat file.txt
# output:
a
b
c
d
git add .
git commit -m "Contributions from friend"
Ok, my friend contributed. Going back to my code (master or main)...
git checkout master
# output:
Switched to branch 'master'
...if I want the incoming changes (e.g., the added last line) to appear as conflict, it is not enough to use the solutions like the one given in the next paraghaph. And a merge will automatically include it without alarm.
Some answer to other similar question (that I couldn't find anymore) pointed out about interactive mode in git, but that is a complicated process of iterating over all changes sequentially and is not portable to other tools/IDE (e.g., Intellij's merge utility or other IDE/diff tools).
Other solution seems to ignore changes on a single branch. Others just mark entire files as conflict, but do not specify them internally with markers <<<
.