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?
CodePudding user response:
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
-f
parameter forgit push
, for examplegit push -f origin master
or something equivalent.