Difference between revisions of "Basic GitHub Tutorial"

From EOVSA Wiki
Jump to: navigation, search
(Created page with "== Introduction == [https://github.com/ GitHub] is a web-based <span class="plainlinks">[https://en.wikipedia.org/wiki/Git Git]</span> <span class="plainlinks">[https://en.wik...")
(No difference)

Revision as of 13:16, 29 October 2016


GitHub is a web-based Git repository hosting service. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project (from wikipedia [1])

We use GitHub to manage and develop software collaboratively. Currently we have two software packages on GitHub: eovsa (for EOVSA system and calibration) and suncasa (for processing and visualize radio imaging spectroscopic data). In the following some very basic instructions are provided to demonstrate the minimal use of GitHub.

Understand GitHub Workflow

A nice and precise description is available here.

Setup GitHub

Register a GitHub account

Too straightforward! Just follow the instructions here.

Setup SSH for remote access

We need to set up remote access to your online GitHub repository. There are multiple methods of doing this, but I am used to the SSH method. Detailed instructions are available here. But here are my steps of doing this. First, check if you already have SSH keys.

ls -al ~/.ssh

By default, the filenames of the public keys are one of the following: id_dsa.pub, id_ecdsa.pub, id_ed25519.pub, id_rsa.pub. If you don't have an existing public and private key pair, or don't wish to use any that are available to connect to GitHub, then generate a new SSH key.

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

You'll be prompted for a few questions. Just press enter to advance. Before adding the new SSH key to the ssh-agent, check if your ssh-agent is running:

eval "$(ssh-agent -s)"

If it says something like "Agent pid 59566", you are good. Now add the SSH key:

ssh-add ~/.ssh/id_rsa

Now that you have a SSH key on your machine, you can proceed and add it to GitHub following these instructions.

Minimal use of GitHub

= Start your own repository from scratch

Now you have a new brilliant idea and want to convert it to working codes. You decided to make up a repository to put your codes in. Go to GitHub and create a new repository there called "myprecious". Then open a terminal window on your computer, create a directory named "myprecious", and add some descriptions in a file called "README.md"

mkdir myprecious
cd myprecious
echo "# myprecious" >> README.md

initialize it to be a local git repository

git init

You were so excited and pulled an all-nighter putting your codes together (remember to save them!). So you have a lot of stuff in your directory "myprecious". You can now add them in to the repository and commit the changes:

git add .
git commit -m "first commit"

You were so proud of yourself and decided to push all the codes to GitHub and claim your trophy! Before that, define your remote repository on GitHub:

git remote add origin https://github.com/your_github_account/myprecious.git

Check your remote destinations:

git remote -v

You'll see something like this:

origin	https://github.com/your_github_account/myprecious.git (fetch)
origin	https://github.com/your_github_account/myprecious.git (push)

Now, push your codes to Github:

git push origin master