What are the most subtle operations with a .git / index file?

Certain commands git, such as git add ..., change the state of a file .git/index, but I believe that some of these operations can be thought of as a series of smaller operations. For instance,

git add foo bar

can be decomposed into

git add foo
git add bar

In fact, maybe (for everyone I know) the above teams can be divided into even “fine-grained” (but still “ .git/index-modeling”) gitteams.

My question is, what minor modifications can be made to a file .git/indexusing commands git? IOW, what are the "atomic" command line operations on .git/index?

I assume that all these teams will be plumbing teams. In addition, if I were to guess, I would suggest that gid add <file>they git rm --cached <file>would approach two of these operations. On the other hand, it git mv <old> <new>can be a compound “atomic” deletion followed by an “atomic” addition ...

EDIT: The motivation for this question is as follows.

The behavioral aspects gitthat I find most confusing are those that lead to file modification .git/index. Everything else is a gitlittle more open to verification. The file .git/index, however, is quite opaque.

For this reason, I would like to better understand how the file changes .git/index.

+3
source share
2 answers

, . git add , ( ) .

, ( ), ( , ..). git ls-files:

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

, git add git rm , . . , git checkout git status . :

C:\Temp\TestRepo>touch file.txt

C:\Temp\TestRepo>git status
# On branch master
nothing to 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

( mtime ( ) ).

, , - - :

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

( flags 0x0000 0x8000, .)

+2

, git - , , , .

Git , git Internals, , .

, :

... git git add git commit - blob , , , , - , .

0

All Articles