2019-06-06 02:56:58 -04:00
---
type: howto
---
2017-07-21 01:01:14 -04:00
# Troubleshooting Git
Sometimes things don't work the way they should or as you might expect when
2017-12-13 04:27:00 -05:00
you're using Git. Here are some tips on troubleshooting and resolving issues
2017-07-21 01:01:14 -04:00
with Git.
2017-12-13 04:27:00 -05:00
## Broken pipe errors on git push
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05:00
'Broken pipe' errors can occur when attempting to push to a remote repository.
When pushing you will usually see:
2017-07-21 01:01:14 -04:00
2019-06-06 02:56:58 -04:00
```text
2017-07-21 01:01:14 -04:00
Write failed: Broken pipe
fatal: The remote end hung up unexpectedly
```
2017-12-13 04:27:00 -05:00
To fix this issue, here are some possible solutions.
### Increase the POST buffer size in Git
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05:00
**If pushing over HTTP**, you can try increasing the POST buffer size in Git's
configuration. Open a terminal and enter:
2017-07-21 01:01:14 -04:00
```sh
git config http.postBuffer 52428800
```
2017-12-13 04:27:00 -05:00
The value is specified in bytes, so in the above case the buffer size has been
2017-07-21 01:01:14 -04:00
set to 50MB. The default is 1MB.
2017-12-13 04:27:00 -05:00
### Check your SSH configuration
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05: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
instructions in the [SSH troubleshooting] docs.
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05:00
There's another option where you can prevent session timeouts by configuring
SSH 'keep alive' either on the client or on the server (if you are a GitLab
admin and have access to the server).
2017-07-21 01:01:14 -04:00
2019-06-06 02:56:58 -04:00
NOTE: **Note:**
Configuring *both* the client and the server is unnecessary.
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05:00
**To configure SSH on the client side**:
2017-07-21 01:01:14 -04:00
2019-06-06 02:56:58 -04:00
- On UNIX, edit `~/.ssh/config` (create the file if it doesn’ t exist) and
add or edit:
2017-07-21 01:01:14 -04:00
2019-07-31 06:29:10 -04:00
```text
Host your-gitlab-instance-url.com
ServerAliveInterval 60
ServerAliveCountMax 5
```
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05: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
session active", set "Seconds between keepalives (0 to turn off)" to `60` .
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05:00
**To configure SSH on the server side**, edit `/etc/ssh/sshd_config` and add:
2017-07-21 01:01:14 -04:00
2019-06-06 02:56:58 -04:00
```text
2017-12-13 04:27:00 -05:00
ClientAliveInterval 60
ClientAliveCountMax 5
```
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05:00
### Running a git repack
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05: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:
```sh
git repack
git push
```
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05:00
### Upgrade your Git client
2017-07-21 01:01:14 -04:00
2017-12-13 04:27:00 -05:00
In case you're running an older version of Git (< 2.9 ) , consider upgrading
to >= 2.9 (see [Broken pipe when pushing to Git repository][Broken-Pipe]).
2017-07-21 01:01:14 -04:00
2019-05-01 02:13:14 -04:00
## `ssh_exchange_identification` error
Users may experience the following error when attempting to push or pull
using Git over SSH:
2019-06-06 02:56:58 -04:00
```text
Please make sure you have the correct access rights
and the repository exists.
2019-05-01 02:13:14 -04:00
...
2019-06-06 02:56:58 -04:00
ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.
2019-05-01 02:13:14 -04:00
```
This error usually indicates that SSH daemon's `MaxStartups` value is throttling
2019-06-06 02:56:58 -04:00
SSH connections. This setting specifies the maximum number of unauthenticated
2019-05-01 02:13:14 -04: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 02:56:58 -04:00
beginning. The default value is `10` .
2019-05-01 02:13:14 -04:00
Increase `MaxStartups` by adding or modifying the value in `/etc/ssh/sshd_config` :
2019-06-06 02:56:58 -04:00
```text
2019-05-01 02:13:14 -04:00
MaxStartups 100
```
2019-06-06 02:56:58 -04:00
Restart SSHD for the change to take effect.
2019-05-01 02:13:14 -04:00
2018-11-13 06:53:07 -05:00
## Timeout during git push/pull
If pulling/pushing from/to your repository ends up taking more than 50 seconds,
2019-06-06 02:56:58 -04:00
a timeout will be issued with a log of the number of operations performed
2018-11-14 04:23:22 -05:00
and their respective timings, like the example below:
2018-11-13 06:53:07 -05:00
2019-06-06 02:56:58 -04:00
```text
2018-11-13 06:53:07 -05: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.
2017-12-13 04:27:00 -05:00
[SSH troubleshooting]: ../../ssh/README.md#troubleshooting "SSH Troubleshooting"
2017-07-21 01:01:14 -04:00
[Broken-Pipe]: https://stackoverflow.com/questions/19120120/broken-pipe-when-pushing-to-git-repository/36971469#36971469 "StackOverflow: 'Broken pipe when pushing to Git repository'"