Locally you're in a repo, but it contains a history different from github. How best to fix that depends on why. You mention in comments that there's a long log - that suggests this repo represents the history of a project, which is presumably not the same project you're trying to sync with. (If it is the same project, then you're going to need to figure out how you got two unrelated histories for the same project, and how you want to resolve that issue; but for now I'm continuing on the assumption that isn't the case.)
So the straightforward thing to do is, create a new local repo for this project. You can do this with git clone
, which will initialize a new repo for you and populate it with the github history. (You don't really want to still be in the existing local repo when you do this. Since I don't know how you organize things on your local computer, I can't say exactly where you should be; but for example if you have a directory where you keep your local repos, cd
to that and then give the git clone
command with your github URL.)
It is possible in a couple different ways to add a remote's history into an existing repo. An alternative to clone
is
git init
git remote origin add <github-url>
git pull
But this shouldn't cause the error you're seeing unless you create at least one commit after the init
and before the pull
.