{"id":13756,"date":"2025-12-16T15:34:10","date_gmt":"2025-12-16T10:04:10","guid":{"rendered":"https:\/\/www.youstable.com\/blog\/?p=13756"},"modified":"2026-09-07T11:09:24","modified_gmt":"2026-09-07T05:39:24","slug":"optimize-git-on-linux","status":"publish","type":"post","link":"https:\/\/www.youstable.com\/blog\/optimize-git-on-linux\/","title":{"rendered":"How to Optimize Git on Linux Server"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">To optimize Git on a Linux server, use bare repositories on fast SSD\/NVMe storage, enable Git maintenance (commit-graph, multi-pack-index), tune pack\/compression settings, enforce Git LFS for large files, reduce network round trips (protocol v2, SSH multiplexing), and schedule automatic garbage collection, repack, and pruning. Secure access with hooks, least-privilege users, and backups.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Optimizing Git on a Linux server is about improving I\/O, CPU, and network efficiency while maintaining repository integrity and security. In this guide, you\u2019ll learn practical, production-safe techniques to optimize Git on Linux servers, from system tuning and Git configs to hooks, large file strategies, and maintenance schedules used on real-world hosting and CI environments.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"search-intent-and-what-youll-learn\"><strong>Search Intent and What You\u2019ll Learn<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The intent is informational and practical: speed up Git clone, fetch, and push; scale large repositories; and keep servers lean. You\u2019ll get a hands-on checklist, recommended <a href=\"https:\/\/www.youstable.com\/blog\/easy-way-to-configure-git-on-linux-server\/\">Git configurations<\/a>, OS-level tweaks, and scripts you can paste into your shell. This guide follows EEAT and reflects 12+ years of server, Git, and hosting experience.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"quick-optimization-checklist-tldr\"><strong>Quick Optimization Checklist (TL;DR)<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use bare repos on SSD\/NVMe with ext4 or XFS.<\/li>\n\n\n\n<li>Enable Git protocol v2 and SSH multiplexing to cut round trips.<\/li>\n\n\n\n<li>Run <code>git maintenance<\/code> to build commit-graph and multi-pack-index.<\/li>\n\n\n\n<li>Tune pack\/compression (balanced CPU vs bandwidth).<\/li>\n\n\n\n<li>Use Git LFS for binaries and <a href=\"https:\/\/www.youstable.com\/blog\/how-to-connect-to-server-via-ssh\/\">enforce via server<\/a> hooks.<\/li>\n\n\n\n<li>Schedule <code>git gc<\/code>, repacks, and pruning during low-traffic hours.<\/li>\n\n\n\n<li>Limit file sizes, protect branches, and enable fast-forwards-only pushes.<\/li>\n\n\n\n<li>Monitor with <code>git count-objects<\/code> and <code>git fsck<\/code>; alert on growth.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"understand-where-git-spends-time\"><strong>Understand Where Git Spends Time<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Git performance is usually constrained by:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Disk I\/O: <\/strong>reading packfiles and writing objects.<\/li>\n\n\n\n<li><strong>CPU: <\/strong>delta computation and compression during pushes\/repack.<\/li>\n\n\n\n<li><strong>Network:<\/strong> round trips and payload size during clone\/fetch.<\/li>\n\n\n\n<li><strong>Repository shape: <\/strong>deep history, huge binary files, monorepos.<\/li>\n\n\n\n<li><strong>Concurrency: <\/strong>CI and multiple users hitting the same repo.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.youstable.com\/blog\/optimize-elasticsearch-on-linux\/\">Optimizing Git on Linux servers<\/a> means balancing these factors for your workload (developer laptops, CI runners, or artifact pushes).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"server-foundation-hardware-filesystem-limits\"><strong>Server Foundation: Hardware, Filesystem, Limits<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"hardware-and-filesystem-choices\"><strong>Hardware and Filesystem Choices<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Storage: Prefer SSD\/NVMe. Git is read-heavy; low latency matters.<\/li>\n\n\n\n<li>Filesystem: ext4 and XFS both work well. Keep default block sizes; enable <code>noatime<\/code> mount option to reduce write overhead.<\/li>\n\n\n\n<li>Backups: Use filesystem-level snapshots where possible (LVM, ZFS). Validate repository integrity post-restore with <code>git fsck<\/code>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Example: mount with noatime (adjust device and path)\nsudo mount -o noatime,defaults \/dev\/nvme0n1p1 \/git<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"kernel-and-user-limits\"><strong>Kernel and User Limits<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Raise open file limits for the git user if serving many repos concurrently.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \/etc\/security\/limits.d\/git.conf\ngit soft nofile 65535\ngit hard nofile 65535<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These values are safe for busy Git servers. Reload session or reboot to apply. Keep kernel defaults unless you have measured bottlenecks; aggressive sysctl tweaks can backfire on mixed workloads.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"faster-ssh-connections\"><strong>Faster SSH Connections<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.youstable.com\/blog\/how-to-enable-ssh-access-for-clients-or-users\/\">Enable SSH<\/a> multiplexing (ControlMaster) so subsequent Git operations reuse the TCP connection.<\/li>\n\n\n\n<li>Enable compression on slower networks; on fast LAN, consider disabling to save CPU.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># ~\/.ssh\/config (on client\/CI)\nHost git.myserver.com\n  User git\n  IdentityFile ~\/.ssh\/id_ed25519\n  ControlMaster auto\n  ControlPath ~\/.ssh\/cm-%r@%h:%p\n  ControlPersist 10m\n  Compression yes<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"repository-architecture-best-practices\"><strong>Repository Architecture Best Practices<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"create-bare-repositories-for-the-server\"><strong>Create Bare Repositories for the Server<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Servers should host bare repositories (no working tree). This reduces disk usage and avoids accidental edits on the server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo adduser --system --shell \/usr\/bin\/git-shell --group --home \/git git\nsudo mkdir -p \/git\/project.git\nsudo chown -R git:git \/git\n\n# Initialize a bare repo\nsudo -u git git init --bare \/git\/project.git<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"protect-branches-and-history\"><strong>Protect Branches and History<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Disallow non-fast-forward pushes for safety and speed.<\/li>\n\n\n\n<li>Use hooks to enforce policies (file size limits, LFS usage, branch protection).<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># In \/git\/project.git\/config\n&#91;receive]\n    denyNonFastforwards = true\n    denyDeletes = true<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"use-git-lfs-for-binaries\"><strong>Use Git LFS for Binaries<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Large binaries inflate packfiles and slow history walks. Use Git LFS for media, archives, and generated artifacts. Enforce via a pre-receive hook that rejects oversized blobs when not tracked by LFS.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Client side (developers\/CI)\ngit lfs install\ngit lfs track \"*.zip\" \"*.png\" \"*.mp4\"\ngit add .gitattributes\ngit commit -m \"Track binaries with LFS\"\n\n# Server side: ensure LFS server available (Gitea, GitLab, or git-lfs standalone)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"shallow-partial-and-sparse-operations\"><strong>Shallow, Partial, and Sparse Operations<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Shallow clones: <code>git clone --depth 1<\/code> for CI to cut bandwidth\/time.<\/li>\n\n\n\n<li>Partial clones: <code>--filter=blob:none<\/code> requires modern Git and server support.<\/li>\n\n\n\n<li>Sparse checkout: pull only subdirectories you need in monorepos.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Partial clone example\ngit clone --filter=blob:none --no-checkout &lt;ssh:\/\/git@server\/git\/project.git&gt; project\ncd project\ngit sparse-checkout init --cone\ngit sparse-checkout set services\/api<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"git-configuration-fast-safe-defaults\"><strong>Git Configuration: Fast, Safe Defaults<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These settings improve packfile access, reduce CPU spikes, and speed up history queries. Apply per repository or globally where appropriate.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Enable protocol v2 (more efficient commands)\ngit config --system protocol.version 2\n\n# Build and use commit-graph (faster log\/blame)\ngit config --system core.commitGraph true\n\n# Enable multi-pack-index for large repos\ngit config --system repack.writeBitmaps true\ngit config --system pack.useSparse true\n\n# Balance compression: lower = faster CPU, higher = smaller network\ngit config --system core.compression 2\ngit config --system pack.compression 2\n\n# GC and maintenance\ngit config --system gc.auto 256\ngit config --system gc.autoPackLimit 50\ngit config --system maintenance.strategy incremental\ngit config --system maintenance.gc.enabled true\ngit config --system maintenance.commit-graph.enabled true\ngit config --system maintenance.incremental-repack.enabled true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For very large repos, tune memory-aware parameters if your server has ample RAM. Test before rolling out globally:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Advanced tuning (use cautiously; measure impact)\ngit config --system pack.window 50\ngit config --system pack.depth 50\ngit config --system pack.windowMemory \"256m\"\ngit config --system pack.packSizeLimit \"2g\"\ngit config --system core.deltaBaseCacheLimit \"256m\"\ngit config --system pack.deltaCacheSize \"256m\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"maintenance-repack-commit-graph-and-pruning\"><strong>Maintenance: Repack, Commit-Graph, and Pruning<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Modern Git provides <code>git maintenance<\/code> to automate key tasks. Schedule it during off-peak hours for busy servers.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># One-time setup inside each bare repo\ngit maintenance start\ngit maintenance run --task=commit-graph\ngit maintenance run --task=incremental-repack\n\n# Cron (as git user): nightly deep maintenance\n# \/etc\/cron.d\/git-maintenance\n0 2 * * * git find \/git -type d -name \"*.git\" -print0 | xargs -0 -I{} bash -lc '\n  cd \"{}\" &amp;&amp; git maintenance run --task=gc &amp;&amp; git commit-graph write --reachable --changed-paths &amp;&amp; git multi-pack-index write --bitmap' <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>git gc --aggressive<\/code> sparingly; it\u2019s CPU-intensive and rarely necessary on active servers. Prefer incremental repacks and MIDX with bitmaps to speed fetch\/clone without long pauses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"network-and-protocol-optimizations\"><strong>Network and Protocol Optimizations<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Protocol v2 reduces round trips and improves fetch performance.<\/li>\n\n\n\n<li>Smart HTTP via NGINX\/Apache with keep-alive can be efficient for public repos; SSH is robust for private\/internal repos.<\/li>\n\n\n\n<li>Right-size compression: low levels for CPU-bound servers, higher for bandwidth-constrained sites.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Example: moderate compression\ngit config --system core.compression 2\ngit config --system pack.compression 2\n\n# For HTTPS backends, ensure keep-alive and HTTP\/1.1 pipelining are enabled in the proxy<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"security-and-access-control-without-slowing-down\"><strong>Security and Access Control Without Slowing Down<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <code>git-shell<\/code> for the git user to restrict command execution.<\/li>\n\n\n\n<li>Protect branches via hooks and deny non-fast-forwards.<\/li>\n\n\n\n<li>Audit with <code>git fsck<\/code> and enable repository-level logging.<\/li>\n\n\n\n<li>Segment repos by Linux permissions and groups; avoid world-writable paths.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Minimal pre-receive hook to block files larger than 50MB unless tracked by LFS\n# \/git\/project.git\/hooks\/pre-receive (make executable)\n#!\/usr\/bin\/env bash\nmax=52428800\nwhile read old new ref; do\n  git rev-list $old..$new | while read commit; do\n    git ls-tree -r -l $commit | awk '$4 &gt; '\"$max\"' {print $5, $4}' | while read path size; do\n      if ! git check-attr -a -- \"$path\" | grep -q 'filter: lfs'; then\n        echo \"Rejecting large non-LFS file: $path ($size bytes)\" &gt;&amp;2\n        exit 1\n      fi\n    done\n  done\ndone<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"monitoring-and-troubleshooting-performance\"><strong>Monitoring and Troubleshooting Performance<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Repository size and objects: <code>git count-objects -vH<\/code><\/li>\n\n\n\n<li>Integrity: <code>git fsck --full<\/code><\/li>\n\n\n\n<li>Packfiles: <code>ls .git\/objects\/pack<\/code> and <code>git multi-pack-index verify<\/code><\/li>\n\n\n\n<li>Server metrics: track CPU, I\/O wait, and network throughput; correlate with push\/fetch peaks.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># Quick health check for all bare repos\nfor r in \/git\/*.git; do\n  echo \"== $r ==\"\n  (cd \"$r\" &amp;&amp; git count-objects -vH | sed 's\/^\/  \/')\ndone<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"example-optimized-setup-on-ubuntu-step-by-step\"><strong>Example: Optimized Setup on Ubuntu (Step-by-Step)<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># 1) Install Git and Git LFS\nsudo apt update &amp;&amp; sudo apt install -y git git-lfs\nsudo git lfs install --system\n\n# 2) Create restricted git user and repo root\nsudo adduser --system --shell \/usr\/bin\/git-shell --group --home \/git git\nsudo mkdir -p \/git &amp;&amp; sudo chown -R git:git \/git\n\n# 3) Initialize a bare repo\nsudo -u git git init --bare \/git\/app.git\n\n# 4) Apply system-wide Git performance settings\nsudo git config --system protocol.version 2\nsudo git config --system core.commitGraph true\nsudo git config --system repack.writeBitmaps true\nsudo git config --system pack.useSparse true\nsudo git config --system core.compression 2\nsudo git config --system pack.compression 2\nsudo git config --system gc.auto 256\nsudo git config --system maintenance.strategy incremental\n\n# 5) Enable maintenance in the repo\nsudo -u git bash -lc 'cd \/git\/app.git &amp;&amp; git maintenance start &amp;&amp; git maintenance run --task=commit-graph'\n\n# 6) Cron: nightly maintenance (2 AM)\necho '0 2 * * * git find \/git -type d -name \"*.git\" -print0 | xargs -0 -I{} bash -lc \"cd \"{}\" &amp;&amp; git maintenance run --task=gc &amp;&amp; git commit-graph write --reachable --changed-paths &amp;&amp; git multi-pack-index write --bitmap\"' | sudo tee \/etc\/cron.d\/git-maintenance\n\n# 7) SSH hardening and multiplexing are configured on clients<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"real-world-tips-from-hosting-environments\"><strong>Real-World Tips from Hosting Environments<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CI clones are the biggest bandwidth sink. Use <code>--depth 1<\/code>, partial clones, and cache mirrors inside your network.<\/li>\n\n\n\n<li>Large monorepos benefit from commit-graph + MIDX + sparse checkout. Rebuild commit-graph after bulk history operations.<\/li>\n\n\n\n<li>Balance compression for your constraint: CPU-bound servers (lower compression), metered WAN links (higher compression).<\/li>\n\n\n\n<li>Use separate disks\/partitions for Git data and logs to isolate I\/O spikes.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019re hosting on a YouStable VPS or <a href=\"https:\/\/www.youstable.com\/blog\/advantages-of-dedicated-server\/\">Dedicated Server<\/a>, you get NVMe-backed plans ideal for Git workloads plus easy snapshots. Our team can pre-configure Git maintenance, SSH multiplexing, and LFS endpoints to accelerate onboarding and CI pipelines.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"common-pitfalls-to-avoid\"><strong>Common Pitfalls to Avoid<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pushing build artifacts into Git (use package registries or LFS).<\/li>\n\n\n\n<li>Running <code>git gc --aggressive<\/code> frequently on active repos.<\/li>\n\n\n\n<li>Leaving protocol v0\/legacy defaults, causing round trips and slow fetches.<\/li>\n\n\n\n<li>Storing repos on HDDs under heavy CI load.<\/li>\n\n\n\n<li>No branch protection or size enforcement\u2014leading to bloated history.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"faqs-optimize-git-on-linux-server\"><strong>FAQs: Optimize Git on Linux Server<\/strong><\/h2>\n\n\n\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"how-do-i-speed-up-git-clone-and-fetch-on-a-linux-server\">How do I speed up git clone and fetch on a Linux server?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">Enable protocol v2, use NVMe storage, and turn on commit-graph and multi-pack-index with bitmaps. For clients and CI, prefer <code>--depth 1<\/code> or <code>--filter=blob:none<\/code>, and enable SSH multiplexing. Keep packfiles compact via scheduled incremental repacks.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"is-git-gc-u002du002daggressive-recommended-on-servers\">Is git gc u002du002daggressive recommended on servers?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">Generally no. It\u2019s CPU-intensive and stalls large repos. Use <code>git maintenance<\/code> with incremental repack, commit-graph, and MIDX with bitmaps. Run deeper maintenance during off-peak hours only after testing.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"whats-the-best-filesystem-for-git-repositories-on-linux\">What\u2019s the best filesystem for Git repositories on Linux?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">ext4 and XFS both perform well for Git. Prioritize SSD\/NVMe and mount with <code>noatime<\/code>. For very large repositories and high concurrency, XFS often scales predictably; ext4 remains a solid default.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"how-should-i-handle-large-files-in-git\">How should I handle large files in Git?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">Use Git LFS for binaries and enforce it with a pre-receive hook that rejects non-LFS blobs over a threshold (for example, 50 MB). Avoid storing build artifacts in Git; use an artifact registry or object storage instead.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h3 id=\"does-lowering-compression-make-git-faster\">Does lowering compression make Git faster?<\/h3>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">Lowering <code>core.compression<\/code> and <code>pack.compression<\/code> reduces CPU load, which can speed pushes on CPU-bound servers. It increases network usage, so choose levels based on your bottleneck. Values 1\u20133 are a good starting point.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\n<script type=\"application\/ld+json\">\n\t{\n\t\t\"@context\": \"https:\/\/schema.org\",\n\t\t\"@type\": \"FAQPage\",\n\t\t\"mainEntity\": [\n\t\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"How do I speed up git clone and fetch on a Linux server?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Enable protocol v2, use NVMe storage, and turn on commit-graph and multi-pack-index with bitmaps. For clients and CI, prefer --depth 1 or --filter=blob:none, and enable SSH multiplexing. Keep packfiles compact via scheduled incremental repacks.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"Is git gc u002du002daggressive recommended on servers?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Generally no. It\u2019s CPU-intensive and stalls large repos. Use git maintenance with incremental repack, commit-graph, and MIDX with bitmaps. Run deeper maintenance during off-peak hours only after testing.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"What\u2019s the best filesystem for Git repositories on Linux?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>ext4 and XFS both perform well for Git. Prioritize SSD\/NVMe and mount with noatime. For very large repositories and high concurrency, XFS often scales predictably; ext4 remains a solid default.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"How should I handle large files in Git?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Use Git LFS for binaries and enforce it with a pre-receive hook that rejects non-LFS blobs over a threshold (for example, 50 MB). Avoid storing build artifacts in Git; use an artifact registry or object storage instead.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"Does lowering compression make Git faster?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Lowering core.compression and pack.compression reduces CPU load, which can speed pushes on CPU-bound servers. It increases network usage, so choose levels based on your bottleneck. Values 1\u20133 are a good starting point.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t\t\t\t]\n\t}\n<\/script>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To optimize Git on a <a href=\"https:\/\/www.youstable.com\/blog\/optimize-ci-cd-on-linux\/\">Linux server,<\/a> combine fast storage, modern Git features (protocol v2, commit-graph, MIDX), disciplined repository practices (LFS, hooks, branch protection), and automated maintenance. Measure, tune, and iterate. If you want a ready-to-go stack with NVMe and managed help, YouStable can provision and optimize your Git hosting environment end to end.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To optimize Git on a Linux server, use bare repositories on fast SSD\/NVMe storage, enable Git maintenance (commit-graph, multi-pack-index), tune [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":14073,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"iawp_total_views":33,"footnotes":""},"categories":[350,2267],"tags":[],"class_list":["post-13756","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledgebase","category-kb-devops"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/comments?post=13756"}],"version-history":[{"count":1,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13756\/revisions"}],"predecessor-version":[{"id":23110,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/posts\/13756\/revisions\/23110"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media\/14073"}],"wp:attachment":[{"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/media?parent=13756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/categories?post=13756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youstable.com\/blog\/wp-json\/wp\/v2\/tags?post=13756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}