I assume the LOCAL and REMOTE files are just what their name suggests, but what are BASE and BACKUP for?
4 Answers
Git performs a three-way merge, finding the common ancestor (aka "merge base") of the two branches you are merging. When you invoke git mergetool on a conflict, it will produce these files suitable for feeding into a typical 3-way merge tool. Thus:
foo.LOCAL: the "ours" side of the conflict - ie, your branch (HEAD) that will contain the results of the mergefoo.REMOTE: the "theirs" side of the conflict - the branch you are merging intoHEADfoo.BASE: the common ancestor. useful for feeding into a three-way merge toolfoo.BACKUP: the contents of file before invoking the merge tool, will be kept on the filesystem ifmergetool.keepBackup = true.
8 Comments
LOCAL is the version in HEAD. BACKUP was the version that was on-disk before you invoked mergetool. It probably contains the diff3 conflict markers and you may have edited it before invoking mergetool.(UPDATED) Clarification:
- What
REMOTEandLOCALrefers to depends on the git command you are executing.
Two examples for git merge and git rebase:
- LOCAL refers to the internally checked out branch by git, while performing your command.
- Meaning in
git checkout A; merge B➜ A =LOCAL, B =REMOTE - Meaning in
git checkout A; rebase B➜ A =REMOTE, B =LOCAL
- Meaning in
BASE is always the the origin of both files ('without any modifications') - independent on the command.
8 Comments
git mergetool.REMOTE is mine?!! that is confusing!According to https://git-scm.com/docs/git-mergetool
When git mergetool is invoked with this tool (either through the -t or --tool option or the merge.tool configuration variable) the configured command line will be invoked with $BASE set to the name of a temporary file containing the common base for the merge, if available; $LOCAL set to the name of a temporary file containing the contents of the file on the current branch; $REMOTE set to the name of a temporary file containing the contents of the file to be merged, and $MERGED set to the name of the file to which the merge tool should write the result of the merge resolution.
However, there seems to be a difference between a rebase command and a merge command.
Merge uses your local branch as LOCAL and the branch you're merging in as REMOTE
Rebase uses your local branch as REMOTE and the branch you're rebasing onto as LOCAL
Comments
I agree with @Shanakor ,one of the the answer is wrong. The so called local or remote basically indicates what git does in terms of “check out/switch branch” . If you are currently at branch A, and if you run git merge B, git stays in your Branch A for merge command, so local is A; if you are currently in Branch A, and you run git rebase B, (or rebase --onto B), internally, git check out /switch to B, and then the local is of course B;
See: https://git-scm.com/docs/git-rebase
Quote: If is specified, git rebase will perform an automatic git switch before doing anything else. Otherwise it remains on the current branch.
