Danny Connolly
Danny Connolly

Reputation: 899

Error when pulling and pushing to github

I was working on a branch for the past few days and when I merged it and tried to push it I've been getting errors like these, can anyone shed any light on this

when pushing:

To [email protected]:****************/88888888888888888.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:****************/88888888888888888.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

when fetching

    error: unable to resolve reference refs/remotes/origin/wishlist: No error
From github.com:****************/88888888888888888
 ! [new branch]      wishlist   -> origin/wishlist  (unable to update local ref)

Upvotes: 3

Views: 2489

Answers (1)

nulltoken
nulltoken

Reputation: 67589

About your pushing issue, GitHub states

Dealing with “non-fast-forward” errors

From time to time you may encounter this error while pushing:

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

 To prevent you from losing history, non-fast-forward
 updates were rejected Merge the remote changes before pushing again. 
 See the 'non-fast forward' section of 'git push --help' for details.

This error can be a bit overwhelming at first, do not fear. Simply put, git cannot make the change on the remote without losing commits, so it refuses the push. Usually this is caused by another user pushing to the same branch. You can remedy this by fetching and merging the remote branch, or using pull to perform both at once.

In other cases this error is a result of destructive changes made locally by using commands like git commit --amend or git rebase. While you can override the remote by adding --force to the push command, you should only do so if you are absolutely certain this is what you want to do. Force-pushes can cause issues for other users that have fetched the remote branch, and is considered bad practice. When in doubt, don’t force-push.


About the fetching issue, can you provide more information by using the verbose mode in the following command (replacing origin by the name of your remote)?

git fetch -v origin

EDIT:

I've just cloned your GitHub repo without a problem. Your local repo might be slightly corrupted. Without a copy of your local config, packed-refs files, logs and refs folders, it may be quite tricky to troubleshoot remotely.

However, there's an easy way to fix the fetching issue. Clone a fresh new version of your GitHub repository, in a different local folder, and re-start from there. This would reset your references and eliminate your issue.

Upvotes: 3

Related Questions