GitHub is a company that implements a web-based version of git: it has a nice web interface and also a place for you to put your projects "into the cloud". GitHub offers all the functionality of git and adss some of its own (like wiki pages for each project, and social-networking-like features like feeds and followers). GitHub has 20+ million users, and it's becoming a virtual meeting place for software developpers, for sharing information and showcasing projects.
In a nutshell, a version control system lets you and your peers work and collaborate on projects, from anywhere. Initially you (or someone else) will create a remote master repository on github for your project. This master repository is hosted remotely, on github. You (and your partners, if any) will then clone (checkout) a private copy of the remote master repository on your local machine. You can clone several copies of the master repo in several locations, if you want. You can make changes to your local copy. When you are done, you stage these changes for commit, and then you push them to the master repository. Once your changes are pushed to the master repo, your partners can get them by "pulling" the changes from the master repo into their local repo. Git automatically merges the changes pulled form the master with the local changes in the local repo. Finally, git has a feature where it keeps a record of all changes, and any change can be recovered and reverted.
An SSH-key consists of a private key and a public key. The public key can be shared with anyone, and the private key needs to be kept confidential (just like a password).
To authenticate using an SSH-key, a user must have an SSH key pair on their local computer. The remote server (in our case, GitHub) will need to know the public key of the user who will want to authenticate. The user will need to copy her public key to the server, in the user's home directory at ~/.SSH/authorized_keys. This fill contains all the public keys that are authorized to log into this account.
How it works:
Using a SSH keys with a passphrase: With SSH-keys, if someone gains access to your computer, they also get access to all systems that authenticate you based on your SSH-key. To add an extra layer of security, you can add a passphrase to your SSH-key. The passphrase is used to encrypt the private SSH-key. Using passphrases is strongly encouraged to reduce the risk of private keys accidentally leaking (e.g. retired hard drives). Using a passphrase provides a second layer of authentication.
If you want to know more about SSH keys, there are lots of resources online; for example SSH essentials at DiGitalOcean.com.
If you have an passphrase on your private SSH key, you will be prompted to enter the passphrase every time you use it to connect to a remote host. You can configure your SSH-agent and add you SSH-key to avoid typing the passphrase everytime you need to authenticate. In a nutshell, you'll need to:
Open a terminal, and:
$ls -al ~/.sshCheck out the listing to see if you have a key. By default, the names of public keys are id_rsa.pub (or ...). If you see an id_rsa.pub file, it means you already have a public key. If you don't see one, then go to the next step and generate one.
SSH keys are 2048 bits by default. This is considered good enough for security. To specify a larger number of bits, include the -b argument followed by the number of bits you would like.
$ssh-keygen -t rsa -b 4096 -C "email@example.com"This uses the RSA algorithm and creates a new public/private SSH key pair on your computer, using the provided email as a label. When it prompts you to enter a file to save the key, press Enter to accept the default. AT the next prompt, type a secure passphrase. A passphrase should be hard to guess, have at least 15 characters, contain a combination if letters and diGits and punctuation characters.
This has generated an RSA SSH key pair, located in the .ssh hidden directory in your home directory. These files are:
~/.ssh/id_rsa <------------ the private key. DO NOT SHARE!!! ~/.ssh/id_rsa.pub <--------- the associate public key. This can be shared freelyIf you generated a passphrase for a private key and you want to change it or remove it, you can do so with the ssh-keygen -p command.
$eval "(ssh-agent -s)"On my platform this shows:
SSH_AUTH_SOCK=/var/folders/vj/z8bp4njs7sjgjn8dlz7xjcwh0000gp/T//ssh-S4FdGNnegrbK/agent.47635; export SSH_AUTH_SOCK; SSH_AGENT_PID=47646; export SSH_AGENT_PID; echo Agent pid 47646;SSH-agent is a program that runs in the background and keeps your SSH-key loaded in memory, so you don't need to enter your passphrase everytime you need to use the key.
Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_rsa
$ ssh-add -K ~/.ssh/id_rsa
pbcopy < ~/.ssh/id_rsa.pubNow go to you GitHub account page. In the upper-right corner, click your profile photo and click Settings. Click SSH and GPG keys. Click "New SSH key". In the In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal Mac, you might call this key "Personal MacBook Air". Paste your key into the "Key" field. Click Add SSH key.
Before you starting using the Git command on the command line, you need to give it a basic configuration. This will tell Git who you are, making it easy for you and your partners to identify who committed code to your shared repository. Replace the email and name strings with your email address and name. If you have not run these commands, then the very first Git commit will fail and tell you to run them.
git config --global user.email "firstname.lastname@example.org" git config --global user.name "Your Name" git config --global push.default simple
cd path-where-you-want-your-local-repoThen you'll presumably create a directory to hold your local repo:
mkdir git-helloworldThen you'll go to that directory:
cd git-helloworldAnd finally you'll clone it
git clone https://classroom.github.com/a/3vGDBo9zOnce cloned, the usual work cycle in Git is pull-edit-commit-push-repeat:
cd path-for-your-local-repo cd git-helloworld git pullNow your local repo is sync-ed with the master repo.
git statusthis will show you what files are modified.
Now stage the files that you want to commit:
git add file-which-you-want-to-commitFor example let's say you modified helloworld.c.
git add helloworld.cYou should never add object files and executables to the repo.
git commit -m "describe what the changes represent"Note that commit does not take file names as arguments, and will update the local repo with the files that have been staged. Files that have not been specifically staged for commit, will not be commited.
That's it! We'll push branching later (pardon the pun).