2019-06-06 06:56:58 +00:00
---
2020-07-29 12:09:45 +00:00
stage: Create
group: Source Code
2020-11-26 06:09:20 +00:00
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
2019-06-06 06:56:58 +00:00
type: howto
---
2021-02-09 18:09:59 +00:00
# Troubleshooting Git **(FREE)**
2017-07-21 05:01:14 +00:00
Sometimes things don't work the way they should or as you might expect when
2017-12-13 09:27:00 +00:00
you're using Git. Here are some tips on troubleshooting and resolving issues
2017-07-21 05:01:14 +00:00
with Git.
2019-09-27 12:06:07 +00:00
## Broken pipe errors on `git push`
2017-07-21 05:01:14 +00:00
2017-12-13 09:27:00 +00:00
'Broken pipe' errors can occur when attempting to push to a remote repository.
2021-01-28 15:09:06 +00:00
When pushing you usually see:
2017-07-21 05:01:14 +00:00
2020-05-20 03:08:04 +00:00
```plaintext
2017-07-21 05:01:14 +00:00
Write failed: Broken pipe
fatal: The remote end hung up unexpectedly
```
2017-12-13 09:27:00 +00:00
To fix this issue, here are some possible solutions.
### Increase the POST buffer size in Git
2017-07-21 05:01:14 +00:00
2019-10-04 09:06:35 +00:00
**If you're using Git over HTTP instead of SSH**, you can try increasing the POST buffer size in Git's
configuration.
Example of an error during a clone:
`fatal: pack has bad object at offset XXXXXXXXX: inflate returned -5`
Open a terminal and enter:
2017-07-21 05:01:14 +00:00
2020-01-30 15:09:15 +00:00
```shell
2017-07-21 05:01:14 +00:00
git config http.postBuffer 52428800
```
2017-12-13 09:27:00 +00:00
The value is specified in bytes, so in the above case the buffer size has been
2017-07-21 05:01:14 +00:00
set to 50MB. The default is 1MB.
2017-12-13 09:27:00 +00:00
### Check your SSH configuration
2017-07-21 05:01:14 +00:00
2017-12-13 09:27:00 +00:00
**If pushing over SSH**, first check your SSH configuration as 'Broken pipe'
errors can sometimes be caused by underlying issues with SSH (such as
authentication). Make sure that SSH is correctly configured by following the
2021-01-28 15:09:06 +00:00
instructions in the [SSH troubleshooting ](../../ssh/README.md#troubleshooting ) documentation.
2017-07-21 05:01:14 +00:00
2021-01-28 15:09:06 +00:00
If you're a GitLab administrator and have access to the server, you can also prevent
session timeouts by configuring SSH `keep alive` either on the client or on the server.
2017-07-21 05:01:14 +00:00
2020-12-04 21:09:29 +00:00
NOTE:
2021-01-28 15:09:06 +00:00
Configuring both the client and the server is unnecessary.
2017-07-21 05:01:14 +00:00
2017-12-13 09:27:00 +00:00
**To configure SSH on the client side**:
2017-07-21 05:01:14 +00:00
2019-06-06 06:56:58 +00:00
- On UNIX, edit `~/.ssh/config` (create the file if it doesn’ t exist) and
add or edit:
2017-07-21 05:01:14 +00:00
2020-05-20 03:08:04 +00:00
```plaintext
2019-07-31 10:29:10 +00:00
Host your-gitlab-instance-url.com
ServerAliveInterval 60
ServerAliveCountMax 5
```
2017-07-21 05:01:14 +00:00
2017-12-13 09:27:00 +00:00
- On Windows, if you are using PuTTY, go to your session properties, then
navigate to "Connection" and under "Sending of null packets to keep
2021-01-28 15:09:06 +00:00
session active", set `Seconds between keepalives (0 to turn off)` to `60` .
2017-07-21 05:01:14 +00:00
2017-12-13 09:27:00 +00:00
**To configure SSH on the server side**, edit `/etc/ssh/sshd_config` and add:
2017-07-21 05:01:14 +00:00
2020-05-20 03:08:04 +00:00
```plaintext
2017-12-13 09:27:00 +00:00
ClientAliveInterval 60
ClientAliveCountMax 5
```
2017-07-21 05:01:14 +00:00
2019-09-27 12:06:07 +00:00
### Running a `git repack`
2017-07-21 05:01:14 +00:00
2017-12-13 09:27:00 +00:00
**If 'pack-objects' type errors are also being displayed**, you can try to
run a `git repack` before attempting to push to the remote repository again:
2020-01-30 15:09:15 +00:00
```shell
2017-12-13 09:27:00 +00:00
git repack
git push
```
2017-07-21 05:01:14 +00:00
2017-12-13 09:27:00 +00:00
### Upgrade your Git client
2017-07-21 05:01:14 +00:00
2017-12-13 09:27:00 +00:00
In case you're running an older version of Git (< 2.9 ) , consider upgrading
2020-04-03 12:09:52 +00:00
to >= 2.9 (see [Broken pipe when pushing to Git repository ](https://stackoverflow.com/questions/19120120/broken-pipe-when-pushing-to-git-repository/36971469#36971469 )).
2017-07-21 05:01:14 +00:00
2019-05-01 06:13:14 +00:00
## `ssh_exchange_identification` error
Users may experience the following error when attempting to push or pull
using Git over SSH:
2020-05-20 03:08:04 +00:00
```plaintext
2019-06-06 06:56:58 +00:00
Please make sure you have the correct access rights
and the repository exists.
2019-05-01 06:13:14 +00:00
...
2019-06-06 06:56:58 +00:00
ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.
2019-05-01 06:13:14 +00:00
```
2020-02-24 03:09:05 +00:00
or
2020-05-20 03:08:04 +00:00
```plaintext
2020-02-24 03:09:05 +00:00
ssh_exchange_identification: Connection closed by remote host
fatal: The remote end hung up unexpectedly
```
2019-05-01 06:13:14 +00:00
This error usually indicates that SSH daemon's `MaxStartups` value is throttling
2020-02-24 03:09:05 +00:00
SSH connections. This setting specifies the maximum number of concurrent, unauthenticated
2019-05-01 06:13:14 +00:00
connections to the SSH daemon. This affects users with proper authentication
credentials (SSH keys) because every connection is 'unauthenticated' in the
2019-06-06 06:56:58 +00:00
beginning. The default value is `10` .
2019-05-01 06:13:14 +00:00
2020-02-24 03:09:05 +00:00
Increase `MaxStartups` on the GitLab server
by adding or modifying the value in `/etc/ssh/sshd_config` :
2019-05-01 06:13:14 +00:00
2020-05-20 03:08:04 +00:00
```plaintext
2020-02-24 03:09:05 +00:00
MaxStartups 100:30:200
2019-05-01 06:13:14 +00:00
```
2020-02-24 03:09:05 +00:00
`100:30:200` means up to 100 SSH sessions are allowed without restriction,
2021-01-28 15:09:06 +00:00
after which 30% of connections are dropped until reaching an absolute maximum of 200.
2020-02-24 03:09:05 +00:00
Once configured, restart the SSH daemon for the change to take effect.
```shell
# Debian/Ubuntu
sudo systemctl restart ssh
# CentOS/RHEL
sudo service sshd restart
```
2019-05-01 06:13:14 +00:00
2019-09-27 12:06:07 +00:00
## Timeout during `git push` / `git pull`
2018-11-13 11:53:07 +00:00
If pulling/pushing from/to your repository ends up taking more than 50 seconds,
2021-01-28 15:09:06 +00:00
a timeout is issued. It contains a log of the number of operations performed
2018-11-14 09:23:22 +00:00
and their respective timings, like the example below:
2018-11-13 11:53:07 +00:00
2020-05-20 03:08:04 +00:00
```plaintext
2018-11-13 11:53:07 +00:00
remote: Running checks for branch: master
remote: Scanning for LFS objects... (153ms)
remote: Calculating new repository size... (cancelled after 729ms)
```
This could be used to further investigate what operation is performing poorly
and provide GitLab with more information on how to improve the service.
2019-12-05 00:07:50 +00:00
## `git clone` over HTTP fails with `transfer closed with outstanding read data remaining` error
2021-01-28 15:09:06 +00:00
If the buffer size is lower than what is allowed in the request, the action fails with an error similar to the one below:
2019-12-05 00:07:50 +00:00
2020-05-20 03:08:04 +00:00
```plaintext
2019-12-05 00:07:50 +00:00
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
```
2021-01-28 15:09:06 +00:00
This can be fixed by increasing the existing `http.postBuffer` value to one greater than the repository size. For example, if `git clone` fails when cloning a 500M repository, you should set `http.postBuffer` to `524288000` . That setting ensures the request only starts buffering after the first 524288000 bytes.
2019-12-05 00:07:50 +00:00
2020-12-04 21:09:29 +00:00
NOTE:
2019-12-05 00:07:50 +00:00
The default value of `http.postBuffer` , 1 MiB, is applied if the setting is not configured.
2020-01-30 15:09:15 +00:00
```shell
2019-12-05 00:07:50 +00:00
git config http.postBuffer 524288000
```