Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make a new github repo of the local with same commit history?

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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:
Initialize this repository with a README or .gitignore or license

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

  1. create a repository WITHOUT any ticks in this picture
  2. Or, if your remote repository has nothing important, you can OVERWRITE it with -f parameter for git push, for example git push -f origin master or something equivalent.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading