{"meta":{"title":"Lidar com erros non-fast-forward","intro":"À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.","product":"Introdução","breadcrumbs":[{"href":"/pt/get-started","title":"Introdução"},{"href":"/pt/get-started/using-git","title":"Usar o Git"},{"href":"/pt/get-started/using-git/dealing-with-non-fast-forward-errors","title":"Erro non-fast-forward"}],"documentType":"article"},"body":"# Lidar com erros non-fast-forward\n\nÀ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.\n\nSe outra pessoa tiver feito push no mesmo branch que você, o Git não poderá fazer push das alterações:\n\n```shell\n$ git push origin main\n> To https://github.com/USERNAME/REPOSITORY.git\n>  ! [rejected]        main -> main (non-fast-forward)\n> error: failed to push some refs to 'https://github.com/USERNAME/REPOSITORY.git'\n> To prevent you from losing history, non-fast-forward updates were rejected\n> Merge the remote changes (e.g. 'git pull') before pushing again. See the\n> 'Note about fast-forwards' section of 'git push --help' for details.\n```\n\nIsso 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:\n\n```shell\n$ git fetch origin\n# Fetches updates made to an online repository\n$ git merge origin YOUR_BRANCH_NAME\n# Merges updates made online with your local work\n```\n\nOu você pode usar `git pull` para executar ambos os comandos ao mesmo tempo:\n\n```shell\n$ git pull origin YOUR_BRANCH_NAME\n# Grabs online updates and merges them with your local work\n```"}