A few days ago, I used the open-source private Git code hosting tool Gogs to set up a Git mirror site. Today, I discovered a problem: it was unable to package and download files in tar.gz format, and could only download them in zip format.

As someone with obsessive-compulsive tendencies, I simply couldn't tolerate this. So I checked the error logs and finally found the cause: the Git version was too old. A simple upgrade could perfectly solve this problem. The following are the steps to upgrade Git:

Upgrade Git

  1. Download the Git 2.7.4 source package:
wget https://github.com/git/git/archive/v2.7.4.tar.gz
  1. Extract it and enter the source directory:
tar zxvf v2.7.4.tar.gz && cd git-2.7.4
  1. Configure the files:
autoconf
  1. Compile Git:
./configure
  1. Install Git:
make && make install
  1. After the installation is complete, use the following command to check the Git version:
git --version

Check whether it is version 2.7.4.

Modify the Configuration

Next, open the /etc/init.d/functions file and add /usr/local/bin to PATH. The entire line should be as follows:

PATH="/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin"

At this point, the problem preventing Gogs from downloading tar.gz files has been perfectly resolved.