Using GitHub at SDSC

Github repositories can be accessed and updated on all SDSC HPC systems. Make sure your local system or laptop can run git.

Suggested On-line Tutorials

Contents::

Create a GitHub Account:

  • See: see https://github.com/join
  • If you do not currently have a GitHub account, you must obtain one prior to attending the SDSC training activities.
  • Working with git and GitHub will be covered in both introductory and advanced training sessions on these tools.

Install Git on Local System

Install git on Linux:

If you want to install git on a Linux-based operating system, you should be able to do so via your operating system's standard package management tool. For example, on any RPM-based Linux distribution, such as Fedora, RHEL, or CentOS, you can use dnf:

$ sudo dnf install git-all

Or on any Debian-based distribution, such as Ubuntu, try apt:

$ sudo apt install git-all

Installing git on Mac OS X:

There are several ways to install git on your Mac. However, probably the easiest way is to install the Xcode Command Line Tools, which you should be able to do by simply tying to run git from your Terminal:

$ git --version

If it's not already installed, you should be prompted to install it.

If the above option does not work or you need a more up-to-date version of git, you can always install it via a binary installer maintained by the git team, which is available for download at:

https://git-scm.com/download/mac.

The download should start immediately.

Installing git on Windows:

  • There are also several ways to install git under Windows. The official binary executable is available for download on the git website is here:

https://git-scm.com/download/win

Cloning a Repository:

  • GitHub supports two ways to clone a repository: (1) Anonymous HTTPS cloning (no account required); (2) Authenticated method using a SSH, which requires authentication to a GitHub account associated with the repository.
  • As an example, we will download the SDSC Jupyter "Notebook Examples" Repository:
  • Anonymous HTTPS Method: click on the option on the GitHub repo

  • To clone the Notebook repository:
    • Open a terminal window on your laptop. Optionally, create a directory to save the repo; cd into that directory
    • In your browser, open the link to the repository web page: https://github.com/sdsc-hpc-training-org/notebook-examples
    • Click on the green "Clone or Download" and select the "Clone with HTTPS" option
    • copy the repository link in the box
    • In your terminal window, type the following command
      $ git clone https://github.com/sdsc-hpc-training-org/notebook-examples.git
      
  • The repository should start downloading in the directory from which you ran the clone command.

  • Authenticated cloning: This method requires that you create a GitHub account and then you must be added to the repository project team.

Checkout a Branch:

  • Make sure you have the main repository cloned locally. Then change to the root of the local repository.
(base) [username@login01 ~]$ git clone https://github.com/sdsc-hpc-training-org/basic_skills.git
Cloning into 'basic_skills'...
remote: Enumerating objects: 330, done.
remote: Counting objects: 100% (330/330), done.
remote: Compressing objects: 100% (240/240), done.
remote: Total 330 (delta 152), reused 160 (delta 58), pack-reused 0
Receiving objects: 100% (330/330), 4.10 MiB | 12.21 MiB/s, done.
Resolving deltas: 100% (152/152), done.
(base) [username@login01 ~]$ cd basic_skills/
  • List all available branches:
(base) [username@login01 basic_skills]$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/basic_skills_branch
  remotes/origin/master   
  • Notice that it lists both the branches that are local and the remote branches on Bitbucket. Using the list as reference, choose the branch you want to checkout. In this example, we want basic_skills_branch.
(base) [username@login01 basic_skills]$ git checkout basic_skills_branch
Branch 'basic_skills_branch' set up to track remote branch 'basic_skills_branch' from 'origin'.
Switched to a new branch 'basic_skills_branch'
(base) [username@login01 basic_skills]$ 
(base) [username@login01 basic_skills]$ 
  • Verify that you have checkout the right branch:
(base) [username@login01 basic_skills]$ 
(base) [username@login01 basic_skills]$ git branch

* basic_skills_branch
  master
(base) [username@login01 basic_skills]$ 
  • At this point, all changes made will affect the branch, not the master