meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
git:issues [2019/07/23 12:48] niziakgit:issues [2023/07/11 16:11] niziak
Line 1: Line 1:
-====== reduce repo size ======+====== Issues ====== 
 + 
 +===== safe.directory ===== 
 + 
 +GIT version changelog: 
 +<code> 
 +2.31.0:  
 +      Two new ways to feed configuration variable-value pairs via 
 +      environment variables have been introduced, and the way 
 +      GIT_CONFIG_PARAMETERS encodes variable/value pairs has been tweaked 
 +      to make it more robust. 
 +</code> 
 + 
 +Related GIT commits: 
 +<code> 
 +f9dbb64fadf599c588a39d2251bb3f9a2f7d572a  2021-01-12 13:27 +0100 Jeff King config: parse more robust format in GIT_CONFIG_PARAMETERS 
 +</code> 
 + 
 +So old 
 + 
 +<file c environment.h> 
 +#define CONFIG_DATA_ENVIRONMENT "GIT_CONFIG_PARAMETERS" 
 +#define CONFIG_COUNT_ENVIRONMENT "GIT_CONFIG_COUNT" 
 +</file> 
 + 
 +====== fsck: dangling commit ===== 
 + 
 +List details about dangling commits ([[https://lukescott.co/2019/05/10/git-finding-lost-dangling-commits/|Git – Finding Lost/Dangling Commits]]: 
 +<code bash> 
 +git fsck --lost-found | grep "^dangling commit" | sed "s/^dangling commit //g" | xargs git show -s --oneline 
 +</code> 
 + 
 +Cleanup: 
 +<code bash> 
 +git reflog expire --expire=now --all 
 +git gc --prune=now --aggressive 
 +git repack -a -d 
 +</code> 
 + 
 +====== Reduce repo size ====== 
  
 It is important to check if git configured with default settings. It is important to check if git configured with default settings.
-Especially forcing of creation of multiple smaller packs significantly increases repo size.+Especially forcing of creation of multiple smaller packs significantly increases repository size. 
 +I.e. changing one 1.2G pack into multiple 256MB packs let, increases size of packs to 4.3GB :(
 <code bash> <code bash>
 git config --global -l git config --global -l
 git config --system -l git config --system -l
 </code> </code>
 +
 Especially take attention for options like: Especially take attention for options like:
   *  deltaCacheSize = 10m   *  deltaCacheSize = 10m
Line 13: Line 55:
  
  
-<code bash> +Command <code bash>git gc</code> and other cleaning commands requires whole repository to be read into memory. For big repos (like kernel.git) it requires to allocate over 8GB of RAM. 
-git count-objects -v +Compression of objects is also performed in RAM, then packs are written onto disc. 
-git gc --aggressive --prune +[[https://stackoverflow.com/questions/42175296/git-gc-uses-a-lot-of-memory-even-i-limited-it]] 
-</code>+ 
 + 
 +To prevent touching existing packs and exhaust system memory paramter ''auto'' should be used. <code bash>git gc --auto</code> 
 +Another possibility is to mark some packs as ''keep'' by creating .keep files. 
  
 Remove unreachable objects: Remove unreachable objects:
 <code bash> <code bash>
 +
 +git count-objects -v
 +git gc  --auto # this is enough to remove loose objects and repack repo
 +git count-objects -v
 +
 +# more instruction
 git repack -Ad # Remove dangling objects from packfiles git repack -Ad # Remove dangling objects from packfiles
 git prune # Remove dangling loose objects git prune # Remove dangling loose objects
-git gc  # repack database 
-</code> 
- 
-<code bash> 
 git gc --aggressive --prune=now --force  || rm -f .git/objects/*/tmp_* && rm -f .git/objects/*/.tmp-* git gc --aggressive --prune=now --force  || rm -f .git/objects/*/tmp_* && rm -f .git/objects/*/.tmp-*
 +
 +git count-objects -v
 </code> </code>