Here explained how to view git remote origin or set remote origin after you started working on git, to check what’s my remote, whether I have been using https or ssh.
View remote origin
- Move to git folder in terminal
git remote set-url origin <url>
This will show you the remote origin
Update remote origin
If you want to change the remote origin, first the get the origin from the git hub
- Login to git hub account
- Open repo
- Click on “Clone or download”option at he right corner
- Copy the url from that by select use ssh/use https
Execute below command to set the remote origin
git remote set-url origin <url>
For instance, git remote set-url origin https://github.com/******************.git
Store Git credentials on file to avoid typing every time when using https
When you set git remote as https, every time it asks user name and password, where as when remote set to ssh, it won’t ask user name and password, but we need to generate ssh keys and set up in our system, internally it will be authenticated when you performing git commands on remote, how to set up ssh key can be found here.
Using credential.helper we can store the credentials on desk that are being entered, from next time it won’t ask credentials.
Run the below command, Git will remember user name and password for future and these will be used every time when it talks to Git remote.
git config credential.helper store
After this command, when you try to interact with remote, you will be asked to enter user name and password. This internally stores credentials in .git-credentials file.
for instance, you trying to push to remote, you will be asked
$ git push -u origin master Username: <type your username> Password: <type your password>
.git-credentials file store in plain text format like below.
https://user:pass@github.com
Here explained how to set/edit git remote and how to store the git credentials so that user won’t enter every time if using https to interact with git.
Leave a Reply