← 返回命令列表

Linux command

git-merge-file 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Three-way merge files

git merge-file [current] [base] [other]

Merge with diff3 style

git merge-file --diff3 [current] [base] [other]

Output to stdout

git merge-file -p [current] [base] [other]

Quiet mode

git merge-file -q [current] [base] [other]

说明

git merge-file performs a three-way merge on individual files. Given the current version, common ancestor, and other version, it produces a merged result with conflict markers where automatic resolution is not possible. The command operates on files outside of Git's normal merge workflow, making it useful for custom merge scenarios or merging files independently. The first file is modified in place with the merge result, and the exit code indicates whether conflicts occurred.

参数

-p, --stdout
Output to stdout.
--diff3
Include base in conflicts.
-q, --quiet
Suppress warnings.
--ours
Resolve conflicts in favor of the "current" version.
--theirs
Resolve conflicts in favor of the "other" version.
--union
Take both sides of each conflict (append rather than mark).
-L _label_
Provide a label for a file (pass up to three times for current/base/other).
--help
Display help information.

FAQ

What is the git-merge-file command used for?

git merge-file performs a three-way merge on individual files. Given the current version, common ancestor, and other version, it produces a merged result with conflict markers where automatic resolution is not possible. The command operates on files outside of Git's normal merge workflow, making it useful for custom merge scenarios or merging files independently. The first file is modified in place with the merge result, and the exit code indicates whether conflicts occurred.

How do I run a basic git-merge-file example?

Run `git merge-file [current] [base] [other]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -p, --stdout do in git-merge-file?

Output to stdout.