. Advertisement .
..3..
. Advertisement .
..4..
Hi everyone, I’m learning about programs. While working, I try undefined. As a result, I get the message:
hint: Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first merge the remote changes (e.g., hint: 'git pull') before pushing again.
What can I do about the “updates were rejected because the remote contains work that you do” issue? Is there a better approach?
The cause: This occurs when you create a new github repository and include a
README
and/orLICENSE
file.The solution: You must merge those newly initialized files with your existing work.
Git pull
is a command that fetches and combines files for you.Now, you’ll be able to push your repository to github at this point.
This error could be caused by the difference in the structure of your code and the code on GitHub. This creates conflict that can be resolved by
Resolving conflicts by merging:
You can use the code if you are sure it is correct.
-f
stands as “force commit”.