Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

! [remote rejected] master -> master (permission denied)

Tags:

git

github

I clone: https://github.com/vy2014/git_lesson.git

Then I make few changes, try to push to remote server by command git push, but error:

Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 273 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To https://github.com/vy2014/git_lesson.git
 ! [remote rejected] master -> master (permission denied)
error: failed to push some refs to 'https://github.com/vy2014/git_lesson.git'

This is git config at local repository (what returned after command git config --list

core.excludesfile=~/.gitignore
core.legacyheaders=false
core.quotepath=false
core.pager=less
mergetool.keepbackup=true
push.default=simple
color.ui=auto
color.interactive=auto
repack.usedeltabaseoffset=true
alias.s=status
alias.a=!git add . && git status
alias.au=!git add -u . && git status
alias.aa=!git add . && git add -u . && git status
alias.c=commit
alias.cm=commit -m
alias.ca=commit --amend
alias.ac=!git add . && git commit
alias.acm=!git add . && git commit -m
alias.l=log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
alias.ll=log --stat --abbrev-commit
alias.lg=log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
alias.llg=log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
alias.d=diff
alias.master=checkout master
alias.spull=svn rebase
alias.spush=svn dcommit
alias.alias=!git config --list | grep 'alias\.' | sed 's/alias\.\([^=]*\)=\(.*\)/\1\     => \2/' | sort
include.path=~/.gitcinclude
include.path=.githubconfig
include.path=.gitcredential
diff.exif.textconv=exif
credential.helper=osxkeychain
filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true
color.ui=true
core.autocrlf=input
push.default=simple
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/vy2014/git_lesson.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

How I push files to GitHub server?

(I use Git version 2.10.0 on macOS Sierra 10.12)

like image 453
Do Nhu Vy Avatar asked Oct 16 '16 10:10

Do Nhu Vy


3 Answers

I'm using Linux that's why answer with osxkeychain don't help me.

And I got same error after enabling 2FA in github

Solution was next:

  1. Generate new SSH key and add it to the ssh-agent
  2. Add new SSH key to GitHub account
  3. Changing remote for repository from https://github.com/username/your-repository.git to [email protected]:username/your-repository.git

It can be done in next way

git remote set-url origin [email protected]:username/your-repository.git
like image 140
chinskiy Avatar answered Sep 18 '22 12:09

chinskiy


As a complementary, I'm on Fedora and met same error.
By typing git config --global --edit, below content is listed. By removing them, everything work fine then.

  [credential]
  helper = store
like image 40
Eugene Avatar answered Sep 17 '22 12:09

Eugene


Type command:

git config --global --edit

Add these lines of configuration at the end of file:

[credential]
  helper = osxkeychain
  useHttpPath = true
like image 23
Do Nhu Vy Avatar answered Sep 17 '22 12:09

Do Nhu Vy