Gray
Gray

Reputation: 387

GIT : failed to push some refs to repo.git

To [email protected]:/Repo.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]:/Repo.git'

Hint: Updates were rejected because a pushed branch tip is behind its remote counterpart. Check out this branch and integrate the remote changes (e.g. 'git pull ...') before pushing again. See the 'Note about fast-forwards' in 'git push --help' for details.`

I got this git error every time I am going to git push -u origin master or git push -f origin master. Yes, I am trying push my committed work and I don't want to reset -hard or rebase because I know my committed work will be gone. Please any idea how to push my work successfully.

Upvotes: 0

Views: 3326

Answers (2)

VonC
VonC

Reputation: 1324268

Please try this on a copy of your local repo:

cd /path/to/your/repo/myrepo
git remote -v # take note of that url

cd ..
git clone myrepo myrepo2
cd myrepo2
git remote set-url origin /url/of/your/remote/repo

Finally, try a git pull --rebase

Or:

git fetch
git rebase origin/master
git push

In both instance, if anything goes wrong, you still have your original work in myrepo.

Upvotes: 2

Satyam Kumar
Satyam Kumar

Reputation: 41

Looks like one of your local branch is behind the remote branch. You need to identify that branch, perform a git pull on it in a seperate branch and then merge that local branch with this new branch. Then perform git push

Upvotes: 0

Related Questions