# Lidar com erros non-fast-forward

Às vezes, o Git não consegue fazer sua mudança em um repositório remoto sem que ocorram perdas de commits. Quando isso acontece, seu push é recusado.

Se outra pessoa tiver feito push no mesmo branch que você, o Git não poderá fazer push das alterações:

```shell
$ git push origin main
> To https://github.com/USERNAME/REPOSITORY.git
>  ! [rejected]        main -> main (non-fast-forward)
> error: failed to push some refs to 'https://github.com/USERNAME/REPOSITORY.git'
> To prevent you from losing history, non-fast-forward updates were rejected
> Merge the remote changes (e.g. 'git pull') before pushing again. See the
> 'Note about fast-forwards' section of 'git push --help' for details.
```

Isso pode ser corrigido [buscando e mesclando](/pt/get-started/using-git/getting-changes-from-a-remote-repository) as alterações feitas na ramificação remota com as alterações feitas localmente:

```shell
$ git fetch origin
# Fetches updates made to an online repository
$ git merge origin YOUR_BRANCH_NAME
# Merges updates made online with your local work
```

Ou você pode usar `git pull` para executar ambos os comandos ao mesmo tempo:

```shell
$ git pull origin YOUR_BRANCH_NAME
# Grabs online updates and merges them with your local work
```