Question: I have installed [GitHub Desktop](https://desktop.github.com/) and Git on a Windows machine. I got a GitHub account and created a dummy repository.

When I intend to upload my package through the [Git Bash](https://superuser.com/questions/1053633/what-is-git-bash-for-windows-anyway) command line, it fails with an error:

```
fatal: refusing to merge unrelated histories

```

I used several ways to overcome these issues by using an existing solution from this community, but still it didn't fix the problem. Is there a trick of working this problem? How can I upload my projects to GitHub successfully?

Answer: 
I am just sharing that rebasing worked for me. I had a new project on GitHub, and a new repository 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 (the first is the GitHub repository, and the second is local):

```
c7f843e Initial Commit (AmitaiB, 4 minutes ago)
97100be Initial commit (Amitai Blickstein, 9 minutes ago)

```

PS: It is funny; I never noticed that the default initial commit message from GitHub is **I**nitial **C**ommit, whereas the local one is **I**nitial **c**ommit (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 the path to your repository directory (e.g., `C:\Users\jvrat\Documents\MSPC`), and `<remote repository URL>` with the URL to your remote repository (e.g., `https://github.com/username/repo_name.git`).