Github Learning

Switching remote URLs between SSH and HTTPS

Check existing remote:

  • If SSH:
    1
    2
    3
    $ git remote -v
    origin git@github.com:USERNAME/REPOSITORY.git (fetch)
    origin git@github.com:USERNAME/REPOSITORY.git (push)
  • If HTTPS:
    1
    2
    3
    $ git remote -v
    origin https://github.com/USERNAME/REPOSITORY.git (fetch)
    origin https://github.com/USERNAME/REPOSITORY.git (push)
    Change your remote’s URL from SSH to HTTPS
    1
    $ git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
    Change your remote’s URL from HTTPS to SSH
    1
    $ git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
    Reference: https://help.github.com/articles/changing-a-remote-s-url/

git push without entering username & password

HTTPS

For the repo which is cloned from GitHub using HTTPS, use a credential helper to remember username and password.

With Git for Windows, run the following commands to store credentials:

1
git config --global credential.helper wincred

SSH

For the repo which is cloned from GitHub using SSH, use SSH keys. -> Generating an SSH Key

Reference:Caching your GitHub password in Git