Git – Error – “git push” failing with error “Updates were rejected because the tip of your current branch is behind”

Background

Trying to update files in one of our public github repositories, but failing with the error message pasted below.

 

Command

Here is the simple command I ran:

git push

That command obviously succeeded git add and git commit.

 

Error

Image

tipofcurrentbranchisbehind-20170126-1014am

 

Textual

To https://github.com/DanielAdeniji/sp_ListObjectLevelPermissions.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://github.com/DanielAdeniji/sp_ListObjectLevelPermissions.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.

Explanation

  1. Key Terms
    • error: failed to push some refs to
    • hint: Updates were rejected because the tip of your current branch is behind

 

Remediation

“Git Reset”

Source

Stack Overflow

What’s the best practice to “git clone” into an existing folder?
Link

stack-overflow-user1055643

 

Code



rem set gitURL
set _gitURL=https://github.com/DanielAdeniji/sp_ListObjectLevelPermissions.git

rem remove git folder
rmdir /S /Q .git 

rem git init
git init

rem git remote add origin to Git URL
git remote add origin %_gitURL%

rem git fetch
git fetch

rem git reset
git reset --mixed origin/master

Explanation

  1. Please replace the variable _gitURL with the your Git Repository

Output

gitreset-20170126-1057am

 

Summary

As always, nothing but the Internet saves.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s