diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2019-03-19 09:39:10 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-03-21 03:07:41 (GMT) |
commit | a7256debd4b6ba9f6ccb94c0958ef48cdd8cb664 (patch) | |
tree | ae02f9142f207d27c8ab68c77e9f259b5db4c911 /Documentation/git-checkout.txt | |
parent | aeb582a98374c094361cba1bd756dc6307432c42 (diff) | |
download | git-a7256debd4b6ba9f6ccb94c0958ef48cdd8cb664.zip git-a7256debd4b6ba9f6ccb94c0958ef48cdd8cb664.tar.gz git-a7256debd4b6ba9f6ccb94c0958ef48cdd8cb664.tar.bz2 |
checkout.txt: note about losing staged changes with --merge
If you have staged changes in path A and perform 'checkout
--merge' (which could result in conflicts in a totally unrelated path
B), changes in A will be gone. Which is unexpected. We are supposed
to keep all changes, or kick and scream otherwise.
This is the result of how --merge is implemented, from the very first
day in 1be0659efc (checkout: merge local modifications while switching
branches., 2006-01-12):
1. a merge is done, unmerged entries are collected
2. a hard switch to a new branch is done, then unmerged entries added
back
There is no trivial fix for this. Going with 3-way merge one file at a
time loses rename detection. Going with 3-way merge by trees requires
teaching the algorithm to pick up staged changes. And even if we detect
staged changes with --merge and abort for safety, an option to continue
--merge is very weird. Such an option would keep worktree changes, but
drop staged changes.
Because the problem has been with us since the introduction of --merge
and everybody has been pretty happy (except Phillip, who found this
problem), I'll just take a note here to acknowledge it and wait for
merge wizards to come in and work their magic. There may be a way
forward [1].
[1] CABPp-BFoL_U=bzON4SEMaQSKU2TKwnOgNqjt5MUaOejTKGUJxw@mail.gmail.com
Reported-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-checkout.txt')
-rw-r--r-- | Documentation/git-checkout.txt | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 8c3d412..3ea4579 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -242,6 +242,8 @@ should result in deletion of the path). + When checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths. ++ +When switching branches with `--merge`, staged changes may be lost. --conflict=<style>:: The same as --merge option above, but changes the way the |