git add - Which plumbing commands achieve the same as git add? -
i'd understand git-plumbing better learning happens when entering
git add $directory and
git add $file how work?
a rough idea can gained reading progit's git internals section.
- if
$directorydirectory,find $directory -type f -exec git add {} \;, i.e. recursively adding files in$directory. then,git add $filenameapplies each file. - a check against
.gitignore(and "superiors") - a check against
.gitattributes, runningcleanfilter if applicable git hash-object -wcleaned contents
and then, index gets updates somehow, involves git mktree. happens there? tree directory contain files added or files committed well? , happens next?
git add not have single equivalent plumbing command, closest 1 git update-index. progit description correct:
replace each directory list of directory's contents. result list of files specified
add, special case handling files known not in directory (i.e., removed), , files special index states (--assume-unchanged,--skip-worktree). in other words, step consults current index.check unstaged-but-ignored (via
.gitignore) files , discard them list (with warning) unless given-f/--force.(side note: have not tested on subdirectories, , it's possible
-fwon't apply subdirectory entry picked recursive scan, names given on command line. if that's case, step 2 must combined step 1, names don't added if we're going ignore them-f.)apply attributes if any, making temporary cleaned copies of files if needed.
use
git update-index --add --remove --replacemodified files written repository, index entries updated, including mode updates. (for files cleaned in step 3, have use separategit hash-object -w, suggested, ,--index-infoinstead of--add --remove --replace.)
the git mktree command not enter process @ all, index flat file using poorly-documented format (or more precisely, 1 of several formats; see --index-version).
the index allows 4 entries per file name, called stages: stage 0 normal cache entry, , stages 1 through 3 conflicted merges. there several special bits marking files removed, or --assume-unchanged, --skip-worktree, --intent-to-add, , special internal use flags, and—even though git not store directories—there index entries directories (which let git @ ctime field of directory, lets git skip unmodified directories quickly, provided can trust os maintain this).
the git mktree command comes play when converting index series of tree objects. git must make 1 tree each subdirectory in index, plus 1 top level tree representing overall index. (subprojects, if exist, in index "gitlink" entries, how appear within whatever tree contains them.)
Comments
Post a Comment