I wanted to give Github a try, so I create an account. To train myself, I created a remote repository, cloned into a folder on my computer, and experimented how to push a file I modified to the remote repository. For this, everything is fine.
Now comes the trouble: to experiment further, I created another remote repository, to which I want to push some code from a local repository. The push operation seems to be fine, as the pictures here below show


As you can see, the branch in my remote repository is called "main", and the branch in my local repository is called "master". The problem is when I try to make the changes effective in the remote repository (i.e. when I try to merge "master" into "main" by clicking the "Compare & pull request" button, if I express myself correctly ?), Github tells me that
There isn’t anything to compare. main and master are entirely different commit histories.

hence I cannot put the changes online. Can someone explain me how to solve that problem ?
N.B.: I use Git Bash to have a command line to execute the operations
Since this is the first commit you need to make sure there is history, so rebase came in help. if conflict happen use git rebase --continue.
git rebase origin/main
git push origin master --force
Check the pulldown to switch branches in the remote repository, located on the left just above the code list. You should be able to toggle between the two, and see everything has been pushed into master. That said, I found your question as it is similar to mine... I have that same error "... main and master are entirely different commit histories" - and being new to doing GitHub right - was trying to (or think I should) pull or merge them together. I did read where 'Main' is supposed to replace 'Master', so it is confusing I have ended up with both. Old repos will continue to use master until GitHub announces a 'seamless' transition for them. I suspect in creating my local repo, I used old instructions from before main was in use, that may have added the master branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With