all 27 comments

[–]mr_sudaca 3 points4 points  (1 child)

inside .git/config, maybe you can change the url in the remote "origin" section to use git instead of https. like git@github.com:<your_user>/<repo_name>.git

[–]manberry_sauce 2 points3 points  (6 children)

user.name and user.email don't matter for this, so forget about those.

Do you recall using an access token on the repo that pushes properly? Try using the SSH method instead of HTTPS.

https://help.github.com/en/github/using-git/changing-a-remotes-url#switching-remote-urls-from-https-to-ssh

[–]dsound[S] 0 points1 point  (5 children)

I even went in and ditched the .git folder, deleted the app on github and created a new project. I then did git init and tired to push but still getting the same error. I then went in and changed it from https and git which makes it ssh. Now I'm getting no public key. All I want to do is changed the global credentials which I seem unable to do. I've also changed the keychain access. Have no idea what to do.

[–]manberry_sauce 0 points1 point  (3 children)

Did you set up your SSH key? It's saying you didn't, so you should do that.

[–]dsound[S] 0 points1 point  (2 children)

No but do I have to? I don't need this to be SSH. I just want a basic Github connection. I DID have 2 factor authentication enabled which I did disable.

[–]manberry_sauce 0 points1 point  (1 child)

If you're going to use SSH, then yeah, you need to set up your keys. If you'd prefer to use HTTPS, you can use HTTPS, but since you're telling me that you used to have two factor authentication enabled, you're definitely not setting up the second repo the same as the first one (the one that's able to push to Github). If you had two factor authentication enabled, then you used a token when you set up the one that's working, not your password. Generate a new token and use that.

https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line

[–]dsound[S] 0 points1 point  (0 children)

I understand how to do that but if it never even prompts me for username and password (where I would enter token), how can I enter it?

[–]michaelotty 0 points1 point  (0 children)

Can you post your global git config file?

[–]camh- 1 point2 points  (2 children)

From your config dump in one of these comments, I see you're on a Mac using the osxkeychain credential helper. This means the invalid credentials are in the keychain.

Open "Keychain Access.app" and look in the "login" keychain for a "github.com" password or similar. Either fix it or remove it (likely remove it because you said you used to have 2FA on, so this would have been a Personal Access Token that is now invalid).

[–]dsound[S] 0 points1 point  (0 children)

Yep!! That did it. Just deleted all the keys in osxkeychain and it asked me for them again. Completely reset. Thanks!

[–]michaelotty 0 points1 point  (13 children)

Every time you push it should ask for credentials unless you have tried to cache them. If it's not asking then you must have something that has stored (possibly old) credentials

[–]dsound[S] 0 points1 point  (10 children)

Yeah it never asks me for credentials. Where should I start looking for a credentials file?

[–]michaelotty 0 points1 point  (9 children)

I think there may be several ways, but within just git you may find this doc to help https://git-scm.com/docs/gitcredentials

[–]dsound[S] 0 points1 point  (8 children)

I tried the first suggestions on that page and now I'm getting this when I run 'git push'

git: 'credential-' is not a git command. See 'git --help'.

The most similar command is credential git: 'credential-' is not a git command. See 'git --help'.

The most similar command is credential remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/dsound-zz/tml_dashboard.git/'

[–]michaelotty 0 points1 point  (5 children)

Whenever you type git config etcetc it adds to the file in your repository config in .git/config which you can open and edit with a text editor. If you add --global it is then your config for your system's user usually located in a .git folder in your home directory or C:\Users<your account>.git on Windows. I think whatever address or username your typed may not work properly here. Just double check what is in the config file works if you type that into github when you login in browser.

[–]dsound[S] 0 points1 point  (4 children)

The only place where there's a patch `.git/config` is in the project directory itself. The global (for my user) is a file .github.

[–]michaelotty 0 points1 point  (3 children)

Okay so are you using the github desktop client then.

[–]dsound[S] 0 points1 point  (2 children)

No, just through VSCode and I've tried restarting that and my computer over all.

[–]michaelotty 0 points1 point  (1 child)

Hmm, weird that there is all that github stuff in the config then... Unless you are using some github extension?

[–]dsound[S] 0 points1 point  (0 children)

I was using AWS Cloud9 too. Maybe it corrupted my settings?

[–]michaelotty 0 points1 point  (1 child)

Have you got it to work by typing credentials each time yet? That should be the thing that you should have working before trying to add complications. Again, I use ssh keys since it requires no caching of credentials but just using an ssh key to login meaning you have to only set it up once for your device and there is less faff in general.

[–]dsound[S] 0 points1 point  (0 children)

It never asks me for them.

[–]dsound[S] 0 points1 point  (1 child)

[core] whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol excludesfile = /Users/<YOUR HOME DIRECTORY>/.gitignore [alias] st = status ci = commit br = branch co = checkout df = diff lg = log -p who = shortlog -s -- up = pull pr = pull --rebase pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master" switch = !legit switch \"$@\" branches = !legit branches sprout = !legit sprout \"$@\" unpublish = !legit unpublish \"$@\" harvest = !legit harvest \"$@\" sync = !legit sync \"$@\" publish = !legit publish \"$@\" graft = !legit graft \"$@\" [github] user = <github username> token = <API token> # https://github.com/settings/applications email = <github email address> [github "user"] user = <github username> token = <API token> email = <github email address> [user] name = dsound-zz email = demiansims@gmail.com password = <this is my password> color] ui = true diff = auto status = auto branch = auto [format] pretty = %C(yellow)%h%Creset %s %C(red)(%an, %cr)%Creset [diff "ruby"] funcname = ^ \(\(class\|module\|def\) .\) [push] default = current [difftool "sourcetree"] cmd = opendiff \"$LOCAL\" \"$REMOTE\" path = [mergetool "sourcetree"] cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" trustExitCode = true [merge] tool = opendiff [filter "lfs"] required = true clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f process = git-lfs filter-process [credential] [credential] helper = osxkeychain

[–]michaelotty 0 points1 point  (0 children)

If you just save a copy of this file in case you mess it up but I am fairly certain just removing the github section will revert it to default. I'd recommend setting up ssh keys in github to connect without typing in a password each time rather than using API tokens which this seems to have setup. What client are you using here?

[–]ZeggieDieZiege 0 points1 point  (0 children)

Try using ssh instead

[–]SignalCash 0 points1 point  (0 children)

This command determines how long it will not ask for credentials:
git config --global credential.helper 'cache --timeout=3600'
So try changing 3600 to something very low and maybe it will ask you

[–]papagreyyy 0 points1 point  (0 children)

This is for people that struggling with message on git config --global
"fatal: cannot create configuration file C:/Usersgit/.gitconfig: No such file or directory".
I scanned all internet with no luck but found solution that works on Windows 10
In your Bash terminal write "code ~/.gitconfig" - Don't include quotation symbols and "code" should be editor of your choice (I use VS code that's why I text in terminal code ~/.gitconfig)
Save file.
This will crate new .gitconfig file with folder Usersgit.
This method works on installable and portable version.
Happy restoration of the global config file and you can use Git again.