Submit code error error: failed to push some refs to

When I wanted to push the local branch of a remote repository, the sudden appearance of an error reminder error: failed to push some refs to.... My heart missed a beat, will not lift This has to be, hands went to google a bit faster than the brain.
Then discovered the error situation occurs even quite diverse. Given their search to the page, the answers are scattered, so this to be a summary, in order to avoid such errors in the future they met, bad memory and prompted me to take the same time to find the same answer.

Branch name is incomplete


emmm, this error is probably the most difficult to find, and not to say that high difficulty factor, but we regard the local master and remote master, for example to write the answers, so we subconsciously ignore local branch and a remote branch name is not the same Happening. (This it may also contain only me ....)

git push complete wording as follows:

  git push @remoteName  @localBranch:@remoteBranch

  // eg.remoteName:origin  localBranch:ceshi  remoteBranch:test
  git push origin ceshi:test

 

But if the local branch and a remote branch name suggests, it is abbreviated. Such as local and remote branch names are the master:

 git push origin master

 

If confirmed the branch name is not wrong, it would continue to look down

Did not commit code


It can be used git statusto check whether forgotten the code submitted go up. If forgotten, submitted on the line.

  git add .
  git commit -m "This is a new commit"
  git push origin master

 

Local and remote conflict


Or a collaborator has submitted the code, or directly on the remote before you make a deal. There is this part of the two treatment methods, one direct and strong coverage, and second, the first change in a remote pull down, post-conflict, and then submit.

Strong coverage

  git push -f origin master
Pull submit git pull –
-rebase origin maste git push origin master

 

Of course, I can recommend is the second on the second, the more rare the better the aesthetics of violence.

Guess you like

Origin www.cnblogs.com/Rivend/p/12065669.html