The error displayed happens basically in the following situation:
- Changes are made to the remote repository and these changes are not applied to the local repository
In your case, the error message specifies the following:
Updates were rejected because the tip of the current branch is delayed compared to the remote repository. Integrate Remote Changes (Using git pull …
) before "send" again.
However, if you have created the repositories independently, for example: you create the repository on Github and also creates a local repository with git init
, the git can interpret that are two distinct projects and in such cases you will get the error below:
fatal: refusing to merge unrelated histories
By default, the git merge
¹ refuses to merge stories that do not share a common ancestor. This is rare to happen, but if it does, you can use the parameter --allow-unrelated-histories.
This parameter can be used to replace this security by combining stories of two projects that started their lives independently, for example:
git pull origin master --allow-unrelated-histories
Attention! You should not use –allow-unrelated-histories
in all cases, unless you know what an unrelated history is and you’re sure you do. Verification was introduced only to prevent disasters when people merge unrelated projects by mistake. ²
¹ The command git pull
is - basically - the junction of commands git fetch
+ git merge
.
Reference:
² https://stackoverflow.com/a/39783462/9101590
https://git-scm.com/docs/git-pull
I have already done the right direction too, in the . git folder, the config file is sending to the link of my properly created directory in Github
– Giovane Machado