> For the complete documentation index, see [llms.txt](https://chadboyce.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chadboyce.gitbook.io/notes/github_tarball.md).

# Downloading a Tarball from GitHub

## 1. Overview

GitHub allows us to fetch a repository in two ways:

1. Using `git clone`
2. Download as a `zip` or `tar`file

Although `git clone` is the most used method, it requires a Git installation on the machine. If Git is not available, we can [download the repository](https://docs.github.com/en/rest/reference/repos#download-a-repository-archive-tar) in tar format and unpack the contents on the file system.

**In this tutorial, we'll look at some Linux commands to download the GitHub repository tarball and unpack it on the file system**.

## 2. Using `curl` Command

We can access any HTTP URL by using the `[curl](/curl-rest)` command. And since GitHub allows us to download the repository archive over HTTP, we can download this tarball using `curl:`

```bash
curl -L  https://github.com/Baeldung/kotlin-tutorials/tarball/master -o dummy.tgz
```

We used the `-L` flag to allow `curl` to follow redirects. This is necessary because GitHub redirects all download requests to an [archive location](https://raw.githubusercontent.com/Baeldung/kotlin-tutorials/tarball/master). **If we skip this flag, we'll get a 302 HTTP status code with redirect headers**.

The above command will download the `.tgz` file to the same location where the `curl` command was executed. Later, we can unpack this file by using the `[tar](/linux/tar-command)` command.

We can also unpack inline:

```bash
curl -L https://github.com/Baeldung/kotlin-tutorials/tarball/master | tar -xz
```

In most cases, `curl` can handshake the HTTPS connection with GitHub. **However, if this connection fails, we can use the insecure option in** `**curl**:`

```bash
curl -L -k https://github.com/Baeldung/kotlin-tutorials/tarball/master | tar -xz
```

## 3. Using `wget` Command

Apart from the `curl` command, which is a general-purpose command to execute HTTP requests, Linux also provides a `[wget](/linux/curl-wget)` command which is a dedicated non-interactive network downloader.

**It supports HTTP and FTP protocols and thus can also be used to download repository archives from GitHub**:

```bash
wget https://github.com/Baeldung/kotlin-tutorials/tarball/master -O dummy.tgz
```

Likewise, the above command will download the `.tgz` file to the same location where the command is executed.

Similar to the `curl`command, we can unpack the archive file inline:

```bash
wget https://github.com/Baeldung/kotlin-tutorials/tarball/master -O - | tar -xz
```

The command `-O` option redirects the archive content to the standard output and acts as an input to the `tar` command.

**Again, similar to the `curl` command, we can skip the HTTPS certificate verification in** `**wget using**` **–no-check-certificate** `:`

```bash
wget --no-check-certificate https://github.com/Baeldung/kotlin-tutorials/tarball/master -O - | tar -xz
```

## 4. Downloading From Private Repositories

The commands we have discussed so far are useful for downloading archives from a public repo. **However, in the case of a private repository, we need to provide GitHub access tokens**:

```bash
curl -L -k -u token:x-oauth-basic https://github.com/Baeldung/kotlin-tutorials/tarball/master | tar -xz
```

Here, the token is an alphanumeric OAuth token which we need to add to the GitHub account.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chadboyce.gitbook.io/notes/github_tarball.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
