Sometimes we don’t like the username on GitHub and want to change it.
Changing the username is Githubis very simple, but if you use GitHub locally, you need to modify some local configurations simultaneously.
This article describes how to change your username from GitHub to modify your git repo settings locally, all in one place.
1 Figure out if you want to change any names
GitHub is easy to change the name. The main thing you need to do is change the remote address of the git folder.
It generally affects several things.
- All previously associated GitHub hyperlinks will be disabled. So think about it, and don’t change the name if you don’t have to
- such as VSCODE’s picgo plugin, when your Github name is changed, the original link should also be modified
- Github associated with the repo address should be modified accordingly
** Special reminder: GitHub user name is recommended to be all lowercase, repo name is also recommended to be all lowercase, so that the input URL is more beautiful, while nickname setting case combination is more appropriate
2 Change Username in GitHub web UI
- In the upper-right corner of any page
Profile Photo – Setting – Account – Change Username, click your profile photo, then click Settings.
- Read the warnings carefully, then click I understand; let’s change my username.
Input your username; once confirmed, you successfully change the username in Github.
3 Change git remote setting
Open the folder you have in your local setting.
(tips, go to the git folder, right-click, then Git Bash Here)
git remote -v # to see your original git repo
git remote set-url origin https://github.com/[Your User name]/[Your repo name].git
Please remember that https://github.com/XXX/XXXX.git is the link to the repo you have after changing your username.
It could get easily from the below steps:
On the GitHub website, click on your repository of interest.
Locate the green button named Code and click on it. The GitHub URL will appear.
Copy the GitHub URL.
Open a Git client such as the BASH shell or GitHub Desktop on your local machine.
Use the GitHub URL to clone the remote repo.
You can type git remote -v again to see if you change the username successfully.
4 Reconnect with username and password
type git push origin master to push changes to your GitHub
It would require you to add a password and username.
Remember that the password is your personal token instead of your GitHub login password.
Or you may meet this message as:
$ git push origin master
libpng warning: iCCP: cHRM chunk does not match sRGB
Login failed, use ctrl+c to cancel basic credential prompt.
Remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for ‘https://github.com/xxxxxxxx/xxxxxx/‘
4.1 Deal with Authentication failed with correct password
if you meet ‘fatal: Authentication failed’ message as above, or ‘ Please use a personal access token instead.’
It means that you need to switch to personal access token in github instead.
steps would be simple:
Profile photo(upper-right corner) -> Setting –> Developer Settings -> Personal access tokens –> generate new token –> done
Please remember that yo need to enable repo (must do)
I recommend you to follow below git
Then click Generate token
Once you see above message, then you are done.
Then you would restart to use your github locally
4.2 Different setting accross different device
For Windows OS ⤴
Go to Credential Manager from Control Panel => Windows Credentials => find git:https://github.com => Edit => On Password replace with with your GitHub Personal Access Token => You are Done
If you don’t find git:https://github.com => Click on Add a generic credential => Internet address will be git:https://github.com and you need to type in your username and password will be your GitHub Personal Access Token => Click Ok and you are done
For macOS ⤴
Click on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type Keychain access then press the Enter key to launch the app => In Keychain Access, search for github.com => Find the internet password entry for github.com => Edit or delete the entry accordingly => You are done
For a Linux-based OS ⤴
For Linux, you need to configure the local GIT client with a username and email address,
$ git config --global user.name "your_github_username" $ git config --global user.email "your_github_email" $ git config -l
Once GIT is configured, we can begin using it to access GitHub. Example:
> Cloning into `Spoon-Knife`... $ Username for 'https://github.com' : username $ Password for 'https://github.com' : give your personal access token here
Now cache the given record in your computer to remembers the token:
$ git config --global credential.helper cache
If needed, anytime you can delete the cache record by:
$ git config --global --unset credential.helper $ git config --system --unset credential.helper
Now try to pull with -v to verify
$ git pull -v
Linux/Debian (Clone as follows):
git clone https://<tokenhere>@github.com/<user>/<repo>.git
(this part from one stackflow post)
Everyway! You are done! Thanks for watching.
More programming skills please visit my website