[rejected] master -> master (fetch first) - Git Giving “fetch first” error when trying to push

1.2K    Asked by DominicPoole in SQL Server , Asked on Apr 20, 2021

I am having my first introduction to git through a class I am taking. I have a number of files in a directory on my computer and am able to stage and commit them without a problem. However, when I try to push files to my github repository, I keep on getting this message “! [rejected] master -> master (fetch first)” as shown below:

 ! [rejected]        master -> master (fetch first)
error: failed to push es were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Can anybody help me out with what this means and how to fix it? I've seen a few people with similar problems online, but I am BRAND NEW to git and not familiar enough with git's command-line language yet. I'm a little hesitant to make certain suggestions, as I don't know whether it will solve the problem or make it worse. Thanks!


Answered by Dominic Poole

Getting this error means: someone has pushed work to the remote repository, to merge it with your work you can run git pull --rebase then push your combined work back to the remote repository.



Your Answer

Interviews

Parent Categories