2

How can I remove the permission of git push?

I've tried reinstalling git and deleting .ssh folder and .gitconfig file on my windows machine.

But I still find I'm able to git push to my repository on github.

The reason I want to do this is because the laptop I'm using now will be given to another coworker in my company after a few days.

This is what I get now:

git push
Everything up-to-date

I want it to be:

git push 
Permission denied (publickey).

[![enter image description here][1]][1]

It seems that the public key stored on github is not used after I type git push.

Are my github account and password stored somewhere in the laptop?

The following is the output of git config --list --show-origin

file:"C:\\ProgramData/Git/config"       core.symlinks=false
file:"C:\\ProgramData/Git/config"       core.autocrlf=true
file:"C:\\ProgramData/Git/config"       core.fscache=true
file:"C:\\ProgramData/Git/config"       color.diff=auto
file:"C:\\ProgramData/Git/config"       color.status=auto
file:"C:\\ProgramData/Git/config"       color.branch=auto
file:"C:\\ProgramData/Git/config"       color.interactive=true
file:"C:\\ProgramData/Git/config"       help.format=html
file:"C:\\ProgramData/Git/config"       diff.astextplain.textconv=astextplain
file:"C:\\ProgramData/Git/config"       rebase.autosquash=true
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    diff.astextplain.textconv=astextplain
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    filter.lfs.clean=git-lfs clean -- %f
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    filter.lfs.smudge=git-lfs smudge -- %f
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    filter.lfs.required=true
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    filter.lfs.process=git-lfs filter-process
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    credential.helper=manager
file:.git/config        core.repositoryformatversion=0
file:.git/config        core.filemode=false
file:.git/config        core.bare=false
file:.git/config        core.logallrefupdates=true
file:.git/config        core.symlinks=false
file:.git/config        core.ignorecase=true
file:.git/config        remote.origin.url=https://github.com/lyenliang/Test.git
file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config        branch.master.remote=origin
file:.git/config        branch.master.merge=refs/heads/master

Maybe I can find some clues from credential.helper=manager.

Brian
  • 12,145
  • 20
  • 90
  • 153
  • What is your repository? Do you work with github, gerrit or something else? Can you paste error which you've get from the server? – grundic May 12 '17 at 09:07
  • I work with github. – Brian May 12 '17 at 09:07
  • Go to your profile settings on GitHub -> SSH and GPG keys, and delete the key for the machine you want to unpair. – medik May 12 '17 at 09:11
  • Update: delete all the keys and see what happens, you're not using them anyway. Are you signed in with the same creds on web and cli? – medik May 12 '17 at 09:19
  • I've cleared all the credentials on my browser. I don't know to sign in with CLI. – Brian May 12 '17 at 09:21
  • Do you find a credential-helper here: `git config --list --show-origin`? Perhaps have a look [here](http://stackoverflow.com/a/15382950/5784831) – Christoph May 12 '17 at 09:38
  • @Christoph, Thank you. The credential is removed after I reboot the laptop. – Brian May 12 '17 at 09:47

1 Answers1

0

The line file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig" credential.helper=manager tells you that a credentail manager is used.

You can see the different levels of config files in the output of git config --list --show-origin:

file:"C:\\ProgramData/Git/config" --> global, user specific
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig" --> system
file:.git/config --> local, user specific

From the documentation here

$(prefix)/etc/gitconfig
System-wide configuration file.
$XDG_CONFIG_HOME/git/config
Second user-specific configuration file. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. Any single-valued variable set in this file will be overwritten by whatever is in ~/.gitconfig. It is a good idea not to create this file if you sometimes use older versions of Git, as support for this file was added fairly recently.
~/.gitconfig
User-specific configuration file. Also called "global" configuration file.
$GIT_DIR/config
Repository specific configuration file.

Important: Local settings always overwrite less local settings

Christoph
  • 6,841
  • 4
  • 37
  • 89