git hub! [rejected] - I can not know the github pro files

0

I'm trying to send my code to GitHub , but I can not. Follow a tutorial, so I'm in the right folder and such. I made a git add all , gave commit at all, git status appears in print for you to take a look, but there the error occurs.

Some attempts before he would also ask for my GitHub login and password, but now not even that.

I do not know how to solve

    
asked by anonymous 21.03.2018 / 13:51

2 answers

2

The displayed error basically occurs 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 current branch's endpoint is late compared to the remote repository. Integrate the remote changes (using git pull … ) before "sending" again.

However, if you have created repositories independently, for example: you create the repository in GitHub and also create a local repository with git init , git can interpret that they are two distinct projects and in these cases you will get the error below:

fatal: refusing to merge unrelated histories

By default, git merge ¹ refuses to merge stories that do not share a common ancestor. This is rare, but if you do, you can use the parameter - -allow-unrelated-histories .

This parameter can be used to override this security by combining stories from 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 make sure you need it. Verification was introduced only to avoid disasters when people merge unrelated projects by mistake. ²

  

¹ The git pull command is - basically - the join of the git fetch + git merge commands.

Reference:
² link
link

    
21.03.2018 / 15:05
2

git is already showing you the problem and the solution:

Updates were rejected because the tip of your current branch is behind

That is, you have the branch outdated because someone has uploaded something to the "remote" area and you have not brought these changes. To resolve, just update to your branch:

git pull

When you do this, you may need to merge files, in which case git will alert you to conflicts. In that case you just have to resolve them, and then "commit" the changes normally.

    
21.03.2018 / 13:55