I had a small project and want to publish it to Github. I already create a local repo, made commit and create a new repo in the github but when I try to push, it says there are commit in the remote that are not represent on my local
Asked
Active
Viewed 26 times
-1
-
1Did you create a repo both locally and on Github.com? Then you have two repos and then you are trying to combine them in a way that is not intended. The easiest workflow for someone new to Git/GitHub I think is to create a repo on GitHub.com and clone the repo to your local computer. Then move the code into that clone. – TheIceBear Aug 14 '23 at 15:55
-
welcome to SO. What you are experiencing is fairly common in new git users. Have you tried researching the error message on SO? – Daemon Painter Aug 14 '23 at 20:36
2 Answers
1
You need to pull the commits that are present on the remote, in order to merge them with your local branch. Then, you can push your changes up to the remote.

Caleb
- 205
- 1
- 8
1
You've created a repo in GitHub and locally, so these repos have unrelated histories. You can force push your local repo to the remote to ‘overwrite’ the state of the repo you created on Github with your local repo. git push --force
or Is there a force push option in GitHub Desktop?.

grg
- 5,023
- 3
- 34
- 50