Git push origin master command returns error

Asked

Viewed 2,907 times

0

$ git push origin master
To https://github.com/MarcusVSouza/cursoGitAlura.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/MarcusVSouza/cursoGitAlura.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

1 answer

4


That mistake means that your branch remote (master) has more recent code updates than yours branch local. Try the following command before doing the git push:

git pull

and then:

git push origin master
  • Hello Antonio, I’ve done this way git pull dps git push keeps returning the msm error.

  • I get it. Try following this answer https://answall.com/questions/272128/o-commandgit-push-n%C3%A3o-est%C3%A1-working-ap%C3%B3s-remove-a-commit

  • I used git push -f and it worked, thanks for the help.

  • 3

    Never force a push like this, always after a pull check the status of your branch, surely other files were inserted in your repository. Another tip, never make changes to the Master branch, always use a secondary branch for this, when finishing the Feature that was in development just merge.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.