If this is your first push, then you might not care about the history on the remote. You could then do a "force push" to skip checks that git does to prevent you from overwriting any existing, or differing, work on remote. Use with extreme care!
just change the
git push **-u** origin master
change it like this!
git push -f origin master
When you created your repository on GitHub, you created a README.md, which is a new commit.
Your local repository doesn't know about this commit yet. Hence:
Updates were rejected because the remote contains work that you do not have locally.
You may want to find to follow this advice:
You may want to first merge the remote changes (e.g., '
git pull
') before pushing again.
That is:
git pull
# Fix any merge conflicts, if you have a `README.md` locally
git push -u origin master
⚡️ EASY: All you need is a forced push. Because you might have created
readme.md
file on Github and you haven't pulled it yet.
git push -f origin master
And here's a GIF.
⚠️ BEWARE: Using force
can change the history for other folks on the same project. Basically, if you don't care about a file being deleted for everyone, just go ahead. Especially if you're the only dev on the project.
Issue a forced push with the command:
git push -f origin master
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