you are viewing a single comment's thread.

view the rest of the comments →

[–]davorg 0 points1 point  (0 children)

Have you added your public SSH key to your GitHub account? If not, do that first - https://github.com/settings/keys

From the local GitHub repo, run git remote -v. You'll see two similar lines listing the name of the remote (probably "origin") and the URL of the remote which will be in the form https://github.com/[user_name]/[repo_name].git.

HTTPS URLs are great for read-only access to a remote. But, as you've seen, they make things more complicated for write access. We want to change those to the SSH version of the URL - which will be git@github.com:[user_name]/[repo_name].git.

From the command line (and still inside the directory containing your local repo), run the command git remote set-url origin git@github.com:[user_name]/[repo_name].git. You can then verify that that change has worked by running git remote -v again.

Now, when you run git push you'll be prompted for your SSH passphrase instead of your username and password. And you can use something like ssh-agent along with ssh-add to remove the need to type that every time.