GitHub
It’s been said that GitHub is to Git what Facebook is to your actual face. What’s that mean? Well, it means that while Facebook is kind of like an online face database (of sorts). GitHub is designed as a Git repository hosting service. And what exactly is a Git repository hosting service? It’s an online database that allows you to keep track of and share your Git version control projects outside of your local computer/server. Unlike Git, GitHub is exclusively cloud-based.
In addition to offering all of the features and advantages of Git, GitHub expands upon Git’s basic functionality. It presents an extremely intuitive, graphically represented user interface, and provides programmers with built-in control and task-management tools. And because GitHub is cloud-based, an individual’s Git repositories can be remotely accessed by any authorized person, from any computer, anywhere in the world (provided it has an internet connection).
Through GitHub, you can share your code with others, giving them the power to make revisions or edits on your various Git branches. This makes it possible for entire teams to coordinate together on single projects in real-time. As changes are introduced, new branches are created, allowing the team to continue to revise the code without overwriting each other's work. These branches are like copies, and changes made on them do not reflect in the main directories on other users’ machines unless users choose to push/pull the changes to incorporate them.
Create an Account
Go to github.com and enter the required user credentials asked on the site and then click on SignUp for GitHub button. Intuitively follow rest of workflow to finish signup and add SSH Key to your github account as described in next section.
Configuring SSH key with GitHub
Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username and personal access token at each visit.
Generating SSH Key
- Open Terminal and Paste the text below, substituting in your GitHub email address.
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
This creates a new SSH key, using the provided email as a label.
- When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
- At the next prompt "Enter passphrase (empty for no passphrase)", press Enter without typing anything and do the same with next prompt.
Adding SSH key to Github
- Run following command and copy the output
$ cat ~/.ssh/id_rsa.pub
- Goto github.com in the upper-right corner of any page, click your profile photo, then click Settings.
- In the user settings sidebar, click SSH and GPG keys.
- Click New SSH key or Add SSH key.
-
In the "Title" field, add a descriptive label for the new key. For example, use your PC name
-
Paste your key (copied in first step) into the "Key" field.
- Click Add SSH key.
- If prompted, confirm your GitHub password.
Creating a new Repository
You can store a variety of projects in GitHub repositories, including open source projects. With open source projects, you can share code to make better, more reliable software. You can use repositories to collaborate with others and track your work.
- In the upper-right corner of any page, use the drop-down menu, and select New repository.
- Type a short, memorable name for your repository. For example, "hello-world".
- Optionally, add a description of your repository. For example, "My first repository on GitHub."
-
Choose a repository visibility. By choosing a repository's visibility: public or private, you can restrict who has access to a repository.
- Public repositories are accessible to everyone on the internet.
- Private repositories are only accessible to you, people you explicitly share access with, and, for organization repositories, certain organization members.
- Keep everything else untouched and Click "Create repository".
Adding local Git Repository to Github Repository
- At the top of your repository on GitHub.com's Quick Setup page, click to copy the remote repository URL. (Make sure SSH is selected)
- In Terminal, add the URL for the remote repository where your local repository will be pushed.
$ git remote add origin <REMOTE_URL>
- Push the changes in your local repository to GitHub.com.
$ git push -u origin master
Cloning Existing Github Repository
- On GitHub.com, navigate to the main page of the repository.
- Above the list of files, click "Code".
- To clone the repository click Use SSH, then click copy icon.
- Open Terminal. Change the current working directory to the location where you want the cloned directory. Type
git clone
, and then paste the URL you copied earlier.
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
Press Enter to create your local clone.