Nishanth Seshadri Nishanth Seshadri - 2 months ago 26
Git Question

cannot push to my git repository

Hey I am having problems trying to push to my git repository. I am getting this error:-

remote: Permission to PLSV/Digital-Treasure.git denied to PLSV-GIBLIB.
fatal: unable to access 'https://github.com/PLSV/Digital-Treasure.git/': The requested URL returned error: 403
.

This is because I have not given access rights to this user. But that is not the problem at hand.

I have 2 user accounts, PLSV and PLSV-GIBLIB. I want only the 1st user name i.e. the former to have access as the email account for the second i.e. the latter has, for some reason become invalid (I want to push to my repository using the account associated with PLSV. So I have tried to make changes in the git configurations using
git config
command in order to get rid of the error, but I do not know what is going wrong. Can someone help me out?

Here are the details from my
git config --list
command :

core.excludesfile=~/.gitignore
core.legacyheaders=false
core.quotepath=false
core.pager=less -r
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
core.user=PLSV
core.email=greasemonkey12394@gmail.com
core.name=PLSV
core.excludesfile=/Users/pavan7vasan/.gitignore_global
user.name=PLSV
user.email=greasemonkey12394@gmail.com
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
core.user=PLSV
core.email=greasemonkey12394@gmail.com
core.name=PLSV
remote.origin.url=https://github.com/PLSV/Digital-Treasure.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master


Please let me know if there are other details that are needed

Answer

I want to push to my repository using the account associated with PLSV.

Note that this has nothing to do with the user.name/user.email configuration: those are settings used when creating commits, not when authenticating to a remote Git repo hosting service like GitHub.

One simple way to make sure you are using the right account when pushing is to embed the account name in the remote origin https url:

git remote set-url origin https://PLSV@github.com/PLSV/Digital-Treasure.git
                                  ^^^^^

That way, each time you are pushing to that remote repo, it will ask for the account PLSV's password.

Comments