Change GitHub account back - github

I have a GitHub account, and I created a new one (temporary, not to replace the old one).
Now, I try to go back to my old account, I changed the email with git config --global user.email = "myuser#email.com" tried to push to an old repo I have connected to my old account, and It says "Permission to X denied to NEW_GITHUB_NAME"
What do I need to do to get back my old account?

Related

Gitlab: tokenless push to github repo?

I've set up an account on github. I've uploaded my ssh public key.
On github I've created a new empty repo.
In my local environment I've set up git to manage a project. Now I'd like to push the project to github.
When I do 'git push -u origin main', I am asked for my username and password.
The first time I did this I received a message that directed me to the use of tokens. So I created a token. However, now I have to input my token ever time I push to github.
Up until recently I was able to push without entering a password/token thanks to the use of ssh keys. Is it possible to still use this?
If so, how do I get it working?
You can configure username and password by default and it wont ask you again and again, but make sure the username has access to that repository.

Git force-push with wrong account

I added a few commits to a branch that I just created locally, squashed them and force-pushed to remote. But when I check on github web UI, it says that I "added the commit" and another person "force-pushed". But the only git account I have ever configured in my terminal is my own git account.
If I do git log locally, the commits have correct username and email (me). It seems that it's only pushing with another person's account, but I don't understand why. Is it because I used to git reset --hard to this person's commit on another branch and this reset somehow changed some configuration of my git? How can I fix this and make github UI show the right person who pushed the commits?
. It seems that it's only pushing with another person's account, but I don't understand why
That would not have anything to do with commit authorship.
It would involve your authentication when pushing: in case of HTTPS URL, check if your credential manager does have the wrong account cached.
printf "host=github.com\nprotocol=https"|git credential-$(git config credential.helper) get
Ran ssh -vT git#github.com. Turns out I was logged in as someone else with a wrong id_rsa file.

I can't switch github accounts in visual studio code terminal

I was logged previously on different account and then successfully logged out of github and logged in to my main account.
But the problem is: when I set up origin, branch, etc it pushes the commits using the credentials that I was logged in as previously.
I tried removing credentials in control panel a few times, restarting the PC and using commands to set github username and github email so they correspond to my main account. Unfortunately, it didn't work.
Every time when I remove the credentials, a windows pops up after the command git push -u origin main
Then I log in to my main account and push some changes, but the commits are not credited to my main account (which it's supposed to be), but instead commits are shown as having been done by the account that I was previously logged in to.
But the commits are not credited to my main account
"Main account" is about authentication (the username/password you enter in the credentials popup)
"commits are about authorship (see the output of git config user.name/git config user.email)
If it a local configuration of your repository (in myrepo/.git/config) that you will find the user name/email used when you create new commits.

Github's password/token stored in keychain and I can't push as another user

So I have a personal and a work's Github account.
After some trial and error I found that the password to Github is stored in the macOS keychain.
That's annoying cause I can't define which account to associate the repo with even though I'd configured my user in ./git/config for that repo.
And the reason it seems is that git will start searching for the global config first. So I removed the global config and keychain and pushed again.
It prompts me for the username password the first time, but stores that into the keychain again and uses that as the default user, not respecting the user I set in ./git/config.
My ideal setup is to have the default user as my personal account and to have the work's account for specific work related repos. How do I do that?
I think the keychain is a bottleneck since it seems to be the first place git is using as authentication.
I found the answer, here
git config credential.username 'your username'
This causes the cli to prompt for a password for that user and it will store that as another entry in the keychain. Will still have to configure git users with git config user.name etc so it knows which user to use.

Can't pull after having a second github account

I have a github account for work. I can't figure out how to create a project/repo outside of the company repo. So, I create another github account and try to push a prototype project, which is not work relative, to the new repo. Now, when I want to push a work project to the work repo, I get
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/<repo-group>/<repo>.git/'
I get a look at the config file under .get of the non-work relative project. There isn't any account relative data.
How to solve this problem?
Run the following, if you haven't:
git config user.name = "YOUR NEW USERNAME"
git config user.email = "YOUR NEW EMAIL"
Also, make sure your are working in the correct master/branch.