Skip to main content
ubuntuask.com

Back to all posts

How to Set Git Compression Level?

Published on
4 min read
How to Set Git Compression Level? image

Best Git Tools to Manage Compression Level to Buy in January 2026

1 Learning Git: A Hands-On and Visual Guide to the Basics of Git

Learning Git: A Hands-On and Visual Guide to the Basics of Git

BUY & SAVE
$34.92 $45.99
Save 24%
Learning Git: A Hands-On and Visual Guide to the Basics of Git
2 Apollo Tools 135 Piece Household Pink Hand Tools Set with Pivoting Dual-Angle 3.6 V Lithium-Ion Cordless Screwdriver - DT0773N1

Apollo Tools 135 Piece Household Pink Hand Tools Set with Pivoting Dual-Angle 3.6 V Lithium-Ion Cordless Screwdriver - DT0773N1

  • VERSATILE TOOL SET FOR ALL DIY PROJECTS & HOME REPAIRS!
  • POWERFUL CORDLESS SCREWDRIVER WITH LED AND RECHARGEABLE BATTERY.
  • SUPPORT BREAST CANCER RESEARCH WITH EVERY PURCHASE!
BUY & SAVE
$34.99
Apollo Tools 135 Piece Household Pink Hand Tools Set with Pivoting Dual-Angle 3.6 V Lithium-Ion Cordless Screwdriver - DT0773N1
3 Version Control with Git: Powerful Tools and Techniques for Collaborative Software Development

Version Control with Git: Powerful Tools and Techniques for Collaborative Software Development

BUY & SAVE
$43.23 $65.99
Save 34%
Version Control with Git: Powerful Tools and Techniques for Collaborative Software Development
4 FASTPRO Pink Tool Set, 220-Piece Lady's Home Repairing Tool Kit with 12-Inch Wide Mouth Open Storage Tool Bag

FASTPRO Pink Tool Set, 220-Piece Lady's Home Repairing Tool Kit with 12-Inch Wide Mouth Open Storage Tool Bag

  • COMPREHENSIVE TOOLKIT FOR ALL YOUR DIY HOME PROJECTS.
  • DURABLE FORGED STEEL PLIERS FOR STRENGTH AND RELIABILITY.
  • STYLISH PINK BAG FOR ORGANIZED TOOLS-GREAT AS A GIFT!
BUY & SAVE
$59.99 $66.99
Save 10%
FASTPRO Pink Tool Set, 220-Piece Lady's Home Repairing Tool Kit with 12-Inch Wide Mouth Open Storage Tool Bag
5 Version Control with Git: Powerful tools and techniques for collaborative software development

Version Control with Git: Powerful tools and techniques for collaborative software development

  • AFFORDABLE PRICES FOR QUALITY USED BOOKS-GREAT SAVINGS!
  • ECO-FRIENDLY CHOICE: REDUCE WASTE BY BUYING SECOND-HAND.
  • THOROUGHLY CHECKED FOR QUALITY-READ WITH CONFIDENCE!
BUY & SAVE
$38.10 $44.99
Save 15%
Version Control with Git: Powerful tools and techniques for collaborative software development
6 Stalwart - 75-HT1007 Household Hand Tools, Tool Set - 6 Piece by , Set Includes – Hammer, Screwdriver Set, Pliers (Tool Kit for the Home, Office, or Car) Black

Stalwart - 75-HT1007 Household Hand Tools, Tool Set - 6 Piece by , Set Includes – Hammer, Screwdriver Set, Pliers (Tool Kit for the Home, Office, or Car) Black

  • COMPLETE TOOLKIT FOR ALL YOUR MINOR HOME MAINTENANCE NEEDS.
  • COMPACT CARRYING CASE FITS ANYWHERE FOR EASY STORAGE AND ACCESS.
  • VERSATILE 6-PIECE SET FOR REPAIRS, ASSEMBLY, AND DIY PROJECTS.
BUY & SAVE
$10.77
Stalwart - 75-HT1007 Household Hand Tools, Tool Set - 6 Piece by , Set Includes – Hammer, Screwdriver Set, Pliers (Tool Kit for the Home, Office, or Car) Black
7 Head First Git: A Learner's Guide to Understanding Git from the Inside Out

Head First Git: A Learner's Guide to Understanding Git from the Inside Out

BUY & SAVE
$50.99 $79.99
Save 36%
Head First Git: A Learner's Guide to Understanding Git from the Inside Out
8 5 Packs Jewelry Pliers Set, Making Tools With Needle/Round/Chain/Bent/Zipper Pliers, Supplies Repair/Cut Kits for Crafting

5 Packs Jewelry Pliers Set, Making Tools With Needle/Round/Chain/Bent/Zipper Pliers, Supplies Repair/Cut Kits for Crafting

  • DURABLE, HIGH-QUALITY TOOLS FOR PRECISE JEWELRY MAKING.

  • VERSATILE FOR REPAIR AND CREATION OF VARIOUS JEWELRY ITEMS.

  • IDEAL GIFT FOR DIY ENTHUSIASTS AND CRAFTY FRIENDS!

BUY & SAVE
$11.99
5 Packs Jewelry Pliers Set, Making Tools With Needle/Round/Chain/Bent/Zipper Pliers, Supplies Repair/Cut Kits for Crafting
+
ONE MORE?

To set the compression level for git, you can use the core.compression configuration variable. By default, Git uses a compression level of -1, which indicates the highest compression level available. To change this, you can set the compression level to a value between 0 and 9, with 0 being no compression and 9 being the highest compression.

To set the compression level to, let's say, 6, you can use the following command:

git config --global core.compression 6

This will set the compression level to 6 for all your repositories. You can also set the compression level for a specific repository by running the command without the --global flag inside the repository directory.

Keep in mind that setting a higher compression level may increase the processing time for Git operations but can reduce the size of the repository on disk. Experiment with different compression levels to find the right balance of speed and size for your needs.

How to revert back to default compression settings in git?

To revert back to the default compression settings in git, you can use the following command:

git config --global core.compression 1

This command sets the compression level to the default value of 1, which is the fastest and uses the least amount of CPU. It is recommended to use this value for most situations unless you have specific performance requirements that require changing the compression level.

You can also reset the compression settings to the default value by removing the compression setting from your git configuration file. To do this, you can use the following command:

git config --global --unset core.compression

After running this command, git will revert back to using the default compression settings.

How to compress git objects only during certain operations?

To compress git objects only during certain operations, you can use the following steps:

  1. Enable git object compression by setting the core.compression configuration option in your git configuration file. You can set this option to a value between 0 and 9, with 0 being no compression and 9 being maximum compression. For example, to set compression level to 4, you can use the following command:

git config --global core.compression 4

  1. Run git gc (garbage collection) command to compress objects in the repository. This can be done using the following command:

git gc

  1. You can also manually trigger git compression during certain operations by using the following command:

GIT_OPTION_TRACE=1 git push

This will output various commands that are run during the push operation, including the git compression command. You can manually run this compression command whenever needed during your operations.

By following these steps, you can control when git object compression is applied in your repository, allowing you to optimize performance during certain operations.

How to set git compression level to maximum?

To set the git compression level to maximum, you can use the following command in your terminal:

git config --global core.compression 9

This command sets the compression level to the maximum value of 9. This will compress the data to the maximum extent possible, potentially reducing the size of your repository but also increasing the amount of time it takes to compress and decompress data.

You can also adjust the compression level to a value between 0 and 9, with 0 being no compression and 9 being the maximum compression level.

What is the difference between fast and slow compression algorithms in git?

Fast compression algorithms in git, such as Zstd or Lz4, prioritize speed and efficiency in terms of compression and decompression times. They are designed to quickly compress and decompress data, which can result in faster performance when working with large repositories or files.

On the other hand, slow compression algorithms in git, such as Gzip or Bzip2, prioritize higher levels of compression to reduce file size. While they can achieve better compression ratios, they come at the cost of increased processing times when compressing and decompressing data.

Ultimately, the choice between fast and slow compression algorithms in git depends on the specific use case and requirements of the user. Fast algorithms are generally preferred for performance-critical applications, while slow algorithms may be more suitable for situations where file size is a primary concern.

How to configure global compression settings in git?

To configure global compression settings in Git, you can use the following command:

git config --global core.compression

Replace <level> with the desired compression level. The compression levels range from 0 to 9, where 0 means no compression and 9 means maximum compression.

For example, to set the global compression level to 6, you can use the following command:

git config --global core.compression 6

You can also check the current compression settings by using the following command:

git config --global core.compression