ChatGPT解决这个技术问题 Extra ChatGPT

Choose Git merge strategy for specific files ("ours", "mine", "theirs")

I am in the middle of rebasing after a git pull --rebase. I have a few files that have merge conflicts. How can I accept "their" changes or "my" changes for specific files?

$ git status
# Not currently on any branch.
# You are currently rebasing.
#   (fix conflicts and then run "git rebase --continue")
#   (use "git rebase --skip" to skip this patch)
#   (use "git rebase --abort" to check out the original branch)
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:  CorrectlyMergedFile
#
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add <file>..." to mark resolution)
#
#       both modified: FileWhereIWantToAcceptTheirChanges
#       both modified: FileWhereIWantToAcceptMyChanges

Normally I just open the file or a merge tool and manually accept all "their" or "my" changes. However, I suspect I'm missing a convenient git command.

Also, note that I will only be able to choose a merge strategy for each file when I see what files hit conflicts an possibly what the conflicts are.

@AbeVoelker I don't think that solves my problem. I want to select a merge strategy for specific files. Also, note that I will only know what merge stragegy to use when I'm in my rebase and see which files have hit conflicts and what the conflicts are.
I edited this question to be more generic: stackoverflow.com/questions/278081/…. Maybe we can close this question as a duplicate of that? Is that appropriate?
@TheShadow That seems reasonable to me.
I wasn't sure if it was appropriate to change the title of the other question to what I did, because I took out the part about resolving binary files. I restored the other question to what it was previously, so this current question still adds value.

佚名

For each conflicted file you get, you can specify

git checkout --ours -- <paths>
# or
git checkout --theirs -- <paths>

From the git checkout docs

git checkout [-f|--ours|--theirs|-m|--conflict=