LeBlaireau
LeBlaireau

Reputation: 17467

Can't push or pull to Github

When I try and pull:

error: cannot open .git/FETCH_HEAD: Permission denied

When I try a push or a push -u origin master:

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

Upvotes: 2

Views: 9482

Answers (2)

David K
David K

Reputation: 690

Reading through the "man git-push" they mention a "git pull" should be enough to resolve this, but since you're getting "error: cannot open .git/FETCH_HEAD: Permission denied" did you perhaps create the clone of the branch using sudo ? If so your files may not be readable by your user. Double check that the file .git/FETCH_HEAD is readable by your user account.

Upvotes: 7

Edwin Bautista
Edwin Bautista

Reputation: 364

Your local copy might not be in-sync with the remote hub.

Here is a good guideline when pulling/pushing from/to github repo:

  1. git stash - to make sure your changes are stash and your copy is reverted to the last commit that is in-sync with the remote.
  2. git pull - pull changes from remote
  3. git stash pop - to merge your changes to latest source code
  4. git mergetool - if there are conflicts, you need to do this before the changes are merged.
  5. git commit - to commit your changes in your local repo
  6. git push - to push your changes to remote.

Upvotes: 3

Related Questions