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:
Pushing to https://github.com/BigMeanCat/CMDA
To https://github.com/BigMeanCat/CMDA
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/BigMeanCat/CMDA'
hint: Updates 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 take certain suggestions, as I don't know whether it will solve the problem or make it worse.
Thanks!
failed to push some refs to errors are often caused when changes are not committed before pushing, issues with Git pre-push hook, incorrect branch name, or the local repository not being in sync with the Git repository.
We can fix the error: failed to push some refs to [remote repo] error in Git using the git pull origin [branch] or git pull --rebase origin [branch] commands. In most cases, the latter fixes the error.
To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch).
I have been taken same error, then I solved this topic with used "--force" command. Briefly, write this command;
git push origin master --force
Attention: Probably, you tried to do push your codes over and over again before , that's why you took this error.My solution overwrite forcefully with your changeset. By this method your repository may cause mismatch other people's. But If you work alone (not like a group working), so you can use easily "--force" as I mentioned above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With