I am a newbie to git and GitHub.
I know the basic cloning, pushing, and merging.
I want to be good at git so I decided to track my code using git.
I made a local repo of my code. I have done 3 commits until now.
I created a new repo on GitHub and tried to push the changes but they won’t merge because of the different commit history, I don’t want to complicate things so, I deleted the repo on Github.
I want to push my local repo with all the commits to a new remote in Github.
Is there any way to do it?
>Solution :
but they won’t merge because of the different commit history
I guess, you have chosen any of the checkboxes while creating a repository in GitHub:

This will make your remote repository NOT empty, with files / commits not exist in your local repository. That is when the "different commit history" generated.
For solution, you should
- create a repository WITHOUT any ticks in this picture
- Or, if your remote repository has nothing important, you can OVERWRITE it with
-fparameter forgit push, for examplegit push -f origin masteror something equivalent.