What are the finest-grained operations on the .git/index file? -
certain git
commands, such git add ...
modify state of .git/index
file, imagine such operations may thought sequence of smaller operations. example,
git add foo bar
may decomposable into
git add foo git add bar
in fact, there may (for know) commands above may broken down "finer-grained" (but still ".git/index
-modifying") git
commands.
my question is, finest-grained modifications can performed on .git/index
file using git
commands? iow, "atomic" command-line operations on .git/index
?
i imagine these commands plumbing commands. also, if had guess, i'd imagine gid add <file>
, git rm --cached <file>
approximate 2 of operations. on other hand, git mv <old> <new>
may composite of "atomic" deletion followed "atomic" addition...
edit: motivation question following.
the aspects of git
's behavior find confusing result in modification of .git/index
file. else git
bit more open inspection. .git/index
file, however, pretty opaque.
for reason, i'd better understanding of how .git/index
file gets modified.
the main index composed of several index entries, , collection of entries represents contents of next commit. when git add
file, adds (or updates) index entry given filename.
the index entry contains several fields both related staged change (the object id , mode) related contents in working directory (the timestamp, file size, etc). can see both of these git ls-files
command:
c:\temp\testrepo>git add file.txt c:\temp\testrepo>git ls-files --stage 100644 9b72baa6b025e0eb1dd8f1fd23bf5d5515012cd6 0 file.txt c:\temp\testrepo>git ls-files --debug file.txt ctime: 1391645170:0 mtime: 1391645172:0 dev: 0 ino: 0 uid: 0 gid: 0 size: 7 flags: 0
generally speaking, 1 uses git add
, git rm
commands add, update , remove entries main index. however, commands update parts of index entries. example, git checkout
, git status
write working directory cache contents of index entry. example:
c:\temp\testrepo>touch file.txt c:\temp\testrepo>git status # on branch master nothing commit, working directory clean c:\temp\testrepo>git ls-files --debug file.txt ctime: 1391645170:0 mtime: 1391645458:0 dev: 0 ino: 0 uid: 0 gid: 0 size: 7 flags: 0
(note updated mtime
(modified time) field in index entry).
the smallest single change can make index in single command flip assume-unchanged bit on file:
c:\temp\testrepo>git update-index --assume-unchanged file.txt c:\temp\testrepo>git ls-files --debug file.txt ctime: 1391645170:0 mtime: 1391645458:0 dev: 0 ino: 0 uid: 0 gid: 0 size: 7 flags: 8000
(note change flags
field 0x0000 0x8000, flipping single bit.)
Comments
Post a Comment