-1

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

Response from Github Desktop

2
  • 1
    Did 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
    Commented Aug 14, 2023 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? Commented Aug 14, 2023 at 20:36

2 Answers 2

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.

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?.

Not the answer you're looking for? Browse other questions tagged or ask your own question.