git errors when trying to upload to github pages.

I have over the past few days created github pages. I have been developing the pages in RMarkdown and uploading to github from my computer.

I open an RStudio project and select “Git/SVN” with :

Version control system: Git

Origin https://github.com/msmith01/master_msmith01.github.io.git

I open up a git shell

What was working was the following:

git add .
git commit -m "upload"
git push

However “randomly” this stopped working.

I get this error:

$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

where

$ git push --set-upstream origin master
To https://github.com/msmith01/master_msmith01.github.io.git
 ! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/msmith01/master_msmith01.github.io.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

So I type:

git push --set-upstream origin master

I get this message:

$ git push --set-upstream origin master
To https://github.com/msmith01/master_msmith01.github.io.git
 ! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/msmith01/master_msmith01.github.io.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

So I type:

git pull

And get this message:

Matt@DESKTOP-B8BLDN5 MSYS ~/Documents/msmith01.github.io (master)
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> master

I type:

git pull https://github.com/msmith01/master_msmith01.github.io.git

And get this message:

$ git pull https://github.com/msmith01/master_msmith01.github.io.git
From https://github.com/msmith01/master_msmith01.github.io
 * branch HEAD -> FETCH_HEAD
fatal: refusing to merge unrelated histories

I understand I am going wrong with this line git pull [https://github.com/msmith01/master\_msmith01.github.io.git ](https://github.com/msmith01/master_msmith01.github.io.git` )

However before, I had no problems uploading from RStudio.

How can re-set the link between my github account and RStudio back to [https://github.com/msmith01/master\_msmith01.github.io.git](https://github.com/msmith01/master_msmith01.github.io.git)?

Hi @msmith01,

Thank you for reaching out.  

The error below normally means that your local branch has a different commit history than the branch you are wanting to push to:

fatal: refusing to merge unrelated histories

If you haven’t tried this already, it may be helpful to make a fresh clone of the repository from your GitHub account (see here for more on that approach Cloning a repository from GitHub ). Once the new clone is complete, you can copy the changes from the previous repository copy to the new copy and commit these changes again to the new repository.

This suggestion and another approach for solution are also discussed here in the community on this thread: How to deal with “refusing to merge unrelated histories” error

Try to upload with git push -f origin master

Good my friends, tankyou!!