Ok, so i have been trying to get this working and its driving me nuts. All want to do is take my project in vscode and upload it to a branch in gitlab.

Here is a list of things i have done :

  1. Set up SSH connection, works fine.
  2. Created a new branch for a project.
  3. Trying to do a "git push origin master" - gives errors.

Errors : Updates were rejected because the tip of your current branch is behind its remote counterpart.

ok, so now i have to pull right? so i do "git pull origin master" then i get an error :

From gitlab.com:psuryateja17/secret-escapes
 * branch            DataChart  -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Could someone please help me out. Thanks.


This is git's way of letting you know the history of changes in your local (VS Code) and remote (Gitlab) are different and it doesn't know how to relate them.

This provides a nice background to illustrate it and provides the below command that allows git to attempt to merge the differences in history successfully.

git pull origin master --allow-unrelated-histories

If there's any conflicts (a change in the remote/Gitlab conflicts with a change you made in your local/VS Code), you will need to fix them. You can see these in VS code by doing the following

  1. Click "Source Control" button on left.
  2. See MERGE CHANGES in sidebar.
  3. Those files have merge conflicts.
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.