Using Github helps me share my code easily. In a public repository anyone can view code via the Github website. If you want to work with the code then you can use
git clone to copy the remote repository to your development machine. The easiest way to clone the repository is to use its public http address.
However, if you want to push changes back to a remote repository, then you need to use https or Secure Shell (SSH). As you have to enter your Github username and password each time you do a pull or push, its much simpler to use the SSH protocol
email@example.com:/_username_/_repository_, especially once you have to set up a public key for a secure shell (SSH) connection to Github.
I create a new repository for my emacs-clojure-kickstart project and then run the git command to clone the remote repository to my local machine:
git clone https://github.com/jr0cket/Emacs-clojure-kickstart
The remote repository is set to use what ever protocol I specify when cloning, so in this case the remote will be contacted using https. If I want to push changes then I have to remember my github password and type it into the command line (or add it to my github client configuration).
If I use the
firstname.lastname@example.org... address of my github repository, then I can push changes and the git client will authenticate using my SSH public key.
git clone email@example.com:jr0cket/Emacs-clojure-kickstart.git
So what if I come back to a project after a few days and I have forgotten how it was set up. How do I see what protocol I am using and how do I change it if its wrong.
Use the command git remote to see what protocol is set up, the -v option gives you the URL as without it you just get the names of the remote repositories.
git remote -v
If you need to change the remote address, then use
git remote set-url new-url. So assuming I have set up the remote to use http and I want to change it to git, I would use the following command:
git remote set-url firstname.lastname@example.org:jr0cket/Emacs-clojure-kickstart.git
Now I can commit and push changes to the remote server without having to enter my password each time, saving my brain for the coding challenge at hand.
See the post on password protecting your SSH key.
This work is licensed under a Creative Commons Attribution 4.0 ShareAlike License, including custom images & stylesheets. Permissions beyond the scope of this license may be available at @jr0cket