When resolving a merge conflict in Git, what does the term 'ours' refer to?
Think about which branch you have checked out when you start the merge.
'Ours' refers to the branch you currently have checked out, the branch you are merging into. 'Theirs' refers to the branch you are merging from.
You have a merge conflict in a file named app.js. You run the command git checkout --ours app.js followed by git add app.js. What will be the content of app.js after these commands?
'--ours' means to keep your current branch's version of the file.
The command git checkout --ours app.js replaces the conflicted file with the version from your current branch, discarding the incoming changes.
You are merging a feature branch into your main branch and want to resolve all conflicts by accepting the changes from the feature branch (theirs). Which sequence of commands correctly achieves this for all conflicted files?
Remember that --theirs means the branch you are merging in.
After starting the merge, git checkout --theirs . replaces all conflicted files with the incoming branch's versions. Then staging and committing completes the resolution.
You run git checkout --theirs README.md but get the error: error: pathspec 'README.md' did not match any files. What is the most likely cause?
'--theirs' only works on files with merge conflicts.
The --theirs option only applies to files currently in conflict. If README.md is not conflicted, Git cannot find a 'theirs' version to check out.
During a complex merge conflict involving multiple files, you want to keep your current branch's changes for configuration files but accept incoming changes for source code files. Which approach best achieves this?
Selective checkout of 'ours' or 'theirs' per file allows fine control.
Using git checkout --ours on config files keeps your branch's versions, while git checkout --theirs on source files accepts incoming changes. Staging and committing finalizes the resolution.