Objective: I have a main branch and a somebranch in a git repo. I want to apply only the last commit from somebranch to main. To do that, I try to use cherry-pick.
The git tree looks like this:
and file tree looks like:
/src
main.py
Before the cherry-pick, main.py looks like this:
def foo(s):
# Foo says...
print(f'Foo says {s}')
def bar(s):
# Bar says...
print(f'Bar says {s}')
if __name__ == "__main__":
pass
added foo does this:
and added bar:
The command I used:
git checkout main
git cherry-pick <added bar commit id>
But... instead of git simply adding the modifications I expected, ie, adding bar, it shows the following merge conflict window:
line 10 foo("hello") is a modification pertaining to added foo, which is not included in my cherry-pick. So why are these modifications showing up in this merge tool? The modifications from added bar and some commit appear highlighted in yellow, and are what I would actually expect to have showing up, only.



