Remove git from terminal (online solutions not working)(Mac OSX) - macos

I used my old github account and now that is deactivated and i have a new one now. I want it to communicate with my new github username. I've tried many internet solutions and re-installing git and the command line tools. Whenever i type in git remote -v
origin https://github.com/OldUsername/App.git (fetch)
origin https://github.com/OldUsername/App.git (push)
This account is now deactivated so there is no way to use it, I've tried doing the
git config --global user.email "YOUR EMAIL ADDRESS"
git config user.name "Username"
I've been trying for hours and still can't figure out how to get my command line to be able to push to new projects under my new username.

That's the push setting for the remote in your repository config.
Either go hand edit /.git/config or try something like
git remote set-url origin https://github.com/NewUsername/app.git

Remotes are part of a local repository. You can add, remove, rename, or reconfigure them with various git-remote subcommands. You might consider just nuking the current repository directory if it doesn't contain anything you value and cloning or creating a new one.
Alternatively, you can set the URL for a remote using:
git remote set-url origin <new URL>

Related

Gitbash changing github account

I was using github account A on gitbash and I wanted to switch to B.
I deleted the credentials for github from control panel for account A and signed with B
When I run git config --list, user.email and user.name matched with account A
than I did:
git config --global user.name "AccountB'sname"
git config --global user.email AccountBemail
When I run git config --list , Now user.email and user.name matches with account B. And when I make a commit, It is seem to be with account B. So it's good.
My first question is: Is it all to do when changing github account on gitbash ?
2- why on my first git config --list run, name and email did not match even tho I updated credentials from control panel
Your GitHub credentials and your Git config are two unrelated things.
When you set user.name and user.email, what you are changing is the metadata that will be used in any commits your create. Creating commits is a local operation on your machine, and does not involved talking to GitHub or any other Git server.
When you want to connect to GitHub using a different account, you did the right thing: change your credentials for GitHub in the Windows Credentials Manager. That will not affect how commits are created on your machine, only how you will authenticate yourself when connecting to GitHub.

Easy way to switch between accounts on git in the terminal on windows?

Is there a quick way to just log out and log back in with a different account on git in cmd on windows?
I tried:
git config --global --unset user.name
git config --global --unset user.mail
git config --global --unset credential.helper
so I understand I should have been logged out with the old_user_name?
Then I used:
git config --global user.name "new_user_name"
git config --global user.email "new_email"
git push origin master
I got a massage:
remote: Permission to new_user_name/new_repo.git denied to old_user_name.
fatal: unable to access 'https://github.com/new_user_name/new_repo.git/': The requested URL returned error: 403
That means I'm still logged in with the old account. What else can I do?
The user.name and user.email settings are not logins, in any way, shape, or form. (The credential.helper setting is useful here, but just unsetting it is probably not right.)
Whenever you make a new commit (by, e.g., running git commit), Git needs to know what user name and email address to put in the new commit. Git gets these by reading user.name and user.email at that time. That's all they're for: to set these in new commits.1
When you run git push, you do (usually2) need to authenticate in order to send your new commits to some other Git repository. Git does not do this authentication. Git relies on other programs to do it. Those other programs include:
Web servers, via https URLs: here, Git has to send a user name and password or PAT or some other secret to the web server. Git gets these from:
the URL, if they're in the URL;
a credential helper, which you may configure: Windows Git comes with a Windows-specific credential helper, macOS Git comes with a macOS-specific credential helper, and so on; or
as a last resort, reading the user name and password from the keyboard.
Generally the right way to do this is with a credential helper. See the gitcredentials documentation and the specific credential helpers available for your particular Git installation. The problem with method #1 is that the password is visible right there in the URL by anyone looking at your computer; the problem with method #3 is obvious.
Unsetting the credential helper gets you the default for your system. This might not be the best thing to do. For Windows systems, see Remove credentials from Git and in particular VonC's answer here.
Secure Shell (SSH): here, Git simply runs the ssh command. Windows systems come with their own ssh command these days, and Git-for-Windows comes with its own ssh command because the older Windows systems either lacked ssh entirely or provided an inadequate version, so on Windows systems, you must make sure that you configure and use the correct ssh (whatever that may be for your installation).
Since you are using an https:// URL, you will need to set up your credential system. If you wish to use ssh:// URLs, set up ssh.
1Note that git rebase works by copying existing commits to new and (supposedly / intended-to-be) improved ones, so this too uses the settings: it's making new commits.
2One can set up a completely open, anonymous network where anyone can push anything at any time, but these are way too easy to abuse, so nobody does this in practice.

git push origin master denied to user X where x is NOT the user in the local git config

Prefacing this with I am very new to git and github.
I set up a repo on github, as user zzz, and it is correctly listed in my local (repo-specific) git config file, which has entries like the following when I do 'git config --local --list':
remote.origin.url=https://github.com/zzz/myrepo.git
user.name=zzz
user.email=yyy#example.com
But when I do do git push origin master, it get 403 denied to user 'xxx'... a user which corresponds to a completely separate github account. How do I fix this? And why is it picking up user 'xxx' when that is not the user i carefully specified in the local config file? I am on windows 7 machine.
Git store credentials in Windows, clear them referring below image:
Run your git push command, it will prompt you to enter credentials again.
Image Courtesy - Remove credentials from Git

Changed Git username and need to commit/push Xcode project

I am not very familiar with Github.
I changed my username on the web client due to security issues.
I had an Xcode project that I was committing locally and pushing to remote.
I want to push to the same remote but can't since the username is now changed. How do I modify this in Xcode/terminal?
I also want to change the local username to the same one I have on the remote. How/where can I change this
I tried checkout out one of my own GitHub projects (it's public and not that interesting but I'll use it as the example anyway).
When I go to the command line and perform git remote -v I am told:
machine:Clock-Signal user$ git remote -v
origin https://github.com/TomHarte/Clock-Signal.git (fetch)
origin https://github.com/TomHarte/Clock-Signal.git (push)
Supposing I were to change my username to HarteTom then the new remote location of my repository would become:
https://github.com/HarteTom/Clock-Signal.git
Noting that both of those locations are named as 'origin' from the first output I could perform git remote set-url origin https://github.com/HarteTom/Clock-Signal.git. I could confirm that with another git remote -v which would now say:
machine:Clock-Signal user$ git remote -v
origin https://github.com/HarteTom/Clock-Signal.git (fetch)
origin https://github.com/HarteTom/Clock-Signal.git (push)

Can't push branch to github "Use git#github.com:Paratron/spacebattles.git"

I have a working branch in my Mac names database and I would like to push this branch to GitHub and have tried to do this by running:
git push -u origin database
And get the following error message:
You can't push to git://github.com/Paratron/spacebattles.git
Use git#github.com:Paratron/spacebattles.git
Are there known issues that could be the cause for this?
Are there any likely errors I could be doing that results in this error?
Like it says, you can't push to git://github.com/Paratron/spacebattles.git (because it's a read-only URL). Try this:
git remote set-url origin git#github.com:Paratron/spacebattles.git
git push -u origin database
If you haven't ever used git in this way, you need to set it up to work with GitHub first: http://help.github.com/mac-set-up-git/
Also, are you Paratron? If not, you'll need to fork his repository first: http://help.github.com/fork-a-repo/. Then you'll need to use your username instead (git#github.com:YOUR_USERNAME/spacebattles.git).
The URL that you have set for the repository is a readonly URL. You'll need to change the URL for the remote, using remote set-url:
git remote set-url origin git#github.com:Paratron/spacebattles.git

Resources