git checkout –merge <tree-ish> — <paths> not working as expected
When I try to merge my working tree changes to a file with the ones at
tree-ish by checking its path out the former changes are overwritten with the latter changes.
I did not expect this behavior. Instead I would expect Git to replace the file content with conflict markers displayed in the default, merge or diff3 style depending on whether the
--conflict=diff3 option was given to
- What are the downsides to rebasing topic branches instead of merging?
- Will files that are skipped in git cherry-pick be included in a later git merge?
- How to use Git for branches with very similiar code
- Replaced third party code with git submodules, now I can't switch branches
- GIT: how to merge two branches without actually merging files (trivial merge)
- Merge up to a specific commit
Given the following use case:
git init echo foo > foobar git add foobar git commit --message=blabla foobar echo bar > foobar git checkout --conflict=diff3 HEAD -- foobar
I lose the local changes made with
echo bar > foobar.
Also why does the manual page
git-checkout(1) mention the
--conflict=<style> options in the synopsis
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>…? What is the purpose of these two options?
I use git version 1.9.4.msysgit.2 on Microsoft Windows 7.
One Solution collect form web for “git checkout –merge <tree-ish> — <paths> not working as expected”
I see why you expected that behavior — the doc says “when checking out paths from the index” when describing the behavior you’re getting, and this looks like a doc bug to me. Notice that when describing the behavior you want, it says “when switching branches”. I’d [mis]read that pair exactly as you did, and get surprised exactly the same way.
I think that, to describe what it’s doing now accurately, the doc should just say “when checking out paths” and lose the “from the index” part, but I’d also argue for what you want, that “when checking out from a commit or tree [whether or not paths are specified]” for the merge behavior would be a better choice, and also that it should be changed to work that way — a course that’s made easier to justify since atm the doc doesn’t actually say what it’s going to do here