For any given path, there are up to four “version numbers” in the index, numbered 0 (zero) to 3. I will call them “slots”, as if they were actually there for each entry, and then easily (this facilitates their discussion ), although in fact additional versions are introduced dynamically only when necessary. These "virtual slots" may be "empty", that is, the file does not exist.
(In fact, as soon as an entry is created in the index, it is marked bit-by-bit CE_REMOVED
if necessary. It becomes hairy because the entire directory full of files can be marked as “deleted” and then the file can create the name of the previous directory and mark “added.” Let's just pretend that we have fixed slots, there-but-empty, instead. :-))
# 0 - "", "--". , blob-ID (SHA-1) , .
, " ", . "", 1, 2 / 3 . , . "" :
- ( "" , , , , ).
- 1 ( "" ) . ( ), .
- 2 ( "" ) (
HEAD
, ). HEAD
/target-of-merge, . - 3 ( "" ) , . , , .
"git ", # 0 , "", # 1 # 3 , "git rm" , , № 0 , .
, , , ( ) :
gronk
flibby
cleanup
, gronk
breem
, , flibby
. git merge work
, gronk
, flibby
. () .
bleem
flibby
:
$ git checkout cleanup
Switched to branch 'cleanup'
$ git merge work
CONFLICT (modify/delete): flibby deleted in work and modified
in HEAD. Version HEAD of flibby left in tree.
Auto-merging bleem
CONFLICT (content): Merge conflict in bleem
Automatic merge failed; fix conflicts and then commit the result.
$ git ls-files
100644 4362aba7f3b7abf2da0d0ed558cbf5bc0d12e4b0 1 bleem
100644 49db92a61392e9fd691c4af6e1221f408452a128 2 bleem
100644 04b399c8fe321902ce97a1538248878756678ca2 3 bleem
100644 366b52546711401122b791457793a38c033838dd 1 flibby
100644 6fecb1480f45faaabc31b18c91262d03d3767cde 2 flibby
100644 7129c6edb96d08bb44ca1025eb5ae41d41be8903 0 x.txt
() bleem
git show :1:bleem
. gronk
( work
, ), bleem
, git , gronk
bleem
cleanup
. (Git HEAD
, work
, .)
, work
git show :3:bleem
git show work:gronk
, HEAD
: git show HEAD:bleem
, git show cleanup:bleem
git show :2:bleem
( 2 HEAD
aka cleanup
HEAD
).
flibby
, , work
, "" ( 3).
, git add
git rm
, 1 3. , git add
, 0, , .
, 2 3 "" "" . git checkout
(git checkout --ours
git checkout --theirs
2 3 0, , , "" , ), , rebase HEAD
, , "" - . / , : .
, git checkout -m
"" , , 0 "" 1-3 ( , merge.conflictstyle
).