I have installed Github desktop and git on windows machine, I got a github account and created a dummy repository.
When I intend to upload my package through git bash command line, it fails with error: fatal: refusing to merge unrelated histories
I used several ways to overcome this issues by using existing solution from this community, but still didn't fix the problem. Does anyone know any trick of working this problem? How can I upload my projects to github successfully?
Just sharing that rebasing worked for me. I had a new project on GitHub, and a new repo locally that I wanted to link up, and kept getting fatal: refusing to merge unrelated histories
. What worked:
git remote add origin http://github.com/MyName/MyProjectName -f
git branch -u origin/master
git pull -r # R for rebase, makes the magic happen
Output:
First, rewinding head to replay your work on top of it...
Applying: Initial Commit
git log
output (1st is GitHub repo, 2nd is local):
c7f843e Initial Commit (AmitaiB, 4 minutes ago)
97100be Initial commit (Amitai Blickstein, 9 minutes ago)
PS Funny, I never noticed that the default initial commit message from GitHub is Initial Commit, whereas the local one is Initial commit (lowercase). I think I'll send that question in to Jack Handy...
Try the following:
cd /path/to/my/repo
git init
git add --all
git commit -m "Initial commit"
git remote add origin <remote repo URL>
git push -u origin master
Be sure to replace /path/to/my/repo
with path to your repo directory(e.g. C:\Users\jvrat\Documents\MSPC
), and <remote repo URL>
with URL to your remote repo (e.g. https://github.com/username/repo_name.git
).
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